Image optimization for Grunt using imgo.

Image optimization for Grunt using imgo

This plugin requires Grunt 0.4.

Install imgo (see How to install imgo on OS X below for instructions).

npm install grunt-imgo --save-dev

Add to your Gruntfile.js:


Then add section named imgo inside grunt.initConfig(). See next section for details.

Images list: PNG, GIF or JPEG. String or array. Wildcards are supported.

Destination path for images copying before optimizing.

icons: {
    src: 'static/dev/img/*.*',
    dest: 'static/build/img/'

Any options you want to pass to imgo.

icons: {
    src: 'icons/*.png',
    options: '-m -b'

If true task will not be ran. In example, you can skip imgo on Windows (becase of difficult installation):

skip: require('os').platform() === 'win32'
module.exports = function(grunt) {
        imgo: {
            icons: {
                src: 'icons/*.png'
    grunt.registerTask('default', ['imgo']);

Install Homebrew.

Run following commands in terminal:

brew install exiftool imagemagick optipng libjpeg gifsicle
formulas='pngout.rb  defluff.rb cryopng.rb imgo.rb'
for package in $formulas
  brew install ""$package

You may need to use sudo for brew, depending on your setup.

  • dest option (by @smolnikov).
  • Fix options: cannot parse several keys.
  • Verbose output of imgo command.
  • Grunt 0.4 support.
  • file option renamed to src.

The MIT License, see the included file.