jpegoptim is a utility for optimizing JPEG files that provides lossless optimization (based on optimizing the Huffman tables) and "lossy" optimization based on setting a maximum quality factor
You probably want imagemin-jpegoptim
instead.
$ npm install jpegoptim-bin
Make sure you have the correct version of libjpeg. See jpegoptim's README for more information.
import {execFile} from 'child_process';
import jpegoptim from 'jpegoptim-bin';
const args = [
'--overwrite',
'--strip-all',
'--strip-iptc',
'--strip-icc',
'--all-progressive',
'--dest=build',
'input.jpg'
];
execFile(jpegoptim, args, error => {
console.log('Image minified');
});
$ npm install --global jpegoptim-bin
$ jpegoptim --help
MIT © Imagemin