jpeg-recompress (part of JPEG Archive) Node.js wrapper that optimize JPEG images.
Compress JPEGs by re-encoding to the smallest JPEG quality while keeping perceived visual quality the same and by making sure huffman tables are optimized. This is a lossy operation, but the images are visually identical and it usually saves 30-70% of the size for JPEGs coming from a digital camera, particularly DSLRs. By default all EXIF/IPTC/XMP and color profile metadata is copied over, but this can be disabled to save more space if desired.
$ npm install -g jpeg-recompress-bin
var execFile = require('child_process').execFile;
var jpegRecompress = require('jpeg-recompress-bin').path;
execFile(jpegRecompress, ['--quality high', '--min 60', 'input.jpg', 'output.jpg'], function(err) {
if (err) {
throw err;
}
console.log('Image minified');
});
This is licensed under BSD. JPEG Archive is also licensed under MIT.