Negligible Participation Metric
Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

mozjpeg-js

3.3.1 • Public • Published

mozjpeg-js

Implementation of MozJPEG in pure JavaScript, using Emscripten

Usage

$ npm i -S mozjpeg-js

Call mozjpeg.encode with a typed array or buffer of data and an arguments object:

const mozjpeg = require("mozjpeg-js");
const fs = require("fs");
 
const input = fs.readFileSync("in.ppm");
const out = mozjpeg.encode(input, { quality: 85 });
// out = { data: <mozjpeg output>, stderr: <cjpeg stderr> }
 
console.error(out.stderr);
fs.writeFileSync("out.jpg", out.data);

Alternatively, you may specify arguments as an array:

const input = fs.readFileSync("in.ppm");
const out = mozjpeg.encode(input, ["-quality", "85"]);
...
 

You may use any options available in mozjpeg's cjpeg command line utility.

install

npm i mozjpeg-js

Downloadsweekly downloads

28

version

3.3.1

license

BSD-3-Clause

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability