Skip to content

as-com/mozjpeg-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

79108a2 · Apr 3, 2018

History

15 Commits
Apr 3, 2018
Apr 3, 2018
Jun 20, 2016
Apr 3, 2018
Apr 3, 2018
Apr 3, 2018
Apr 3, 2018
Apr 3, 2018
Jun 19, 2016
Apr 3, 2018
Jun 20, 2016
Apr 3, 2018
Apr 3, 2018
Apr 3, 2018
Apr 3, 2018
Apr 3, 2018

Repository files navigation

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.

About

Implementation of MozJPEG in pure JavaScript, using Emscripten

Resources

License

Stars

Watchers

Forks

Packages

No packages published