Set of utilities to run command line tools for image optimization
npm install img-optimOptimize (lossless and lossy compression) images (jpeg, png, gif, svg) using external utilities:
* advpng from AdvanceCOMP
(will use zopfli on default/maximum level 4)
* gifsicle
* jpegoptim
* jpegtran from Independent JPEG Group's JPEG library or jpeg-turbo. In future will be added mozjpeg.
* optipng
* pngcrush
* pngout
* svgo
* pngquant
* pngnq
Based on ImageOptim.app and image_optim ruby gem.
I am expecting you know basics of image optimization, so for each situation you just choose best runner config yourself for your needs.
1. Install from npm.
``sh`
npm install --save img-optim
Tested on 10.9.
`bash`
brew install advancecomp pngcrush optipng pngquant pngnq libjpeg-turbo jpegoptimjpegtran
Note about libjpeg-turbo. It is fork of libjpeg and it can be drop-in replacement for libjpeg (almost in all features), but in brew it is installed keg-only and you will need to specify full path to binary .
Pngout very good for png compression as it implements own deflate algorithm, but it is very-very slow, and sometimes does not gain any advantage (as advpng implemented zopfli - so probably you will not get any advantage). I recommend use it only if you know that you need it.
You can install pngout by downloading and installing the binary versions.
_Note: pngout is free to use even in commercial soft, but you can not redistribute, repackage or reuse it without consent and agreement of creator. license_
svgo is available from NPM.
`bash`
npm install -g svgo
`js
var images = ['./url.gif'];
var Runner = require('./lib/runner');
var runner = new Runner();
runner.run(images, function (err, files) {
console.log(err, files);
});
``