If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-contrib-imagemin --save-dev
Run this task with the
grunt imagemin command.
Minify images using imagemin.
Comes bundled with the following optimizers:
We recommend using grunt-newer to only process changed files as minifying images can be quite slow.
Options will only apply to the relevant files, so you don't need separate targets for png/jpg.
Select optimization level between
The optimization level 0 enables a set of optimization operations that require minimal effort. There will be no changes to image attributes like bit depth or color type, and no recompression of existing IDAT datastreams. The optimization level 1 enables a single IDAT compression trial. The trial chosen is what OptiPNG thinks it’s probably the most effective. The optimization levels 2 and higher enable multiple IDAT compression trials; the higher the level, the more trials.
Level and trials:
Lossless conversion to progressive.
Interlace gif for progressive rendering.
Customize which SVGO plugins to use. More here.
Additional plugins to use with imagemin.
You can either map your files statically or dynamically.
var mozjpeg = ;grunt;grunt;grunt;
cacheoption removed. Adds "pretty-bytes".
pngquantoption is now
falseby default instead of
interlaceoption for GIF files.
pngquant. Cache images so only changed images are optimized. Default
Task submitted by Sindre Sorhus
This file was generated on Mon May 23 2016 17:23:51.