img-optim
v0.0.2
Published
Set of utilities to run command line tools for image optimization
Downloads
17
Maintainers
Readme
img-optim
Optimize (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.
Installation
- Install from npm.
npm install --save img-optim
Binaries installation
OS X: Brew
Tested on 10.9.
brew install advancecomp pngcrush optipng pngquant pngnq libjpeg-turbo jpegoptim
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 jpegtran
.
pngout installation
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 installation
svgo
is available from NPM.
npm install -g svgo
Usage
var images = ['./url.gif'];
var Runner = require('./lib/runner');
var runner = new Runner();
runner.run(images, function (err, files) {
console.log(err, files);
});