Optimize PNG, JPEG, GIF, SVG images with grunt task.
Clone or download
Pull request Compare This branch is 4 commits ahead, 36 commits behind 1000ch:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
screenshot
tasks
test
.gitignore
.travis.yml
gruntfile.js
license.md
package.json
readme.md

readme.md

grunt-image

Optimize PNG, JPEG, GIF, SVG images with grunt task.

Install

$ npm install --save-dev grunt-mega-image

Usage

This is an example of gruntfile.js.

module.exports = function (grunt) {
  grunt.initConfig({
    image: {
      static: {
        options: {
          pngquant: true,
          optipng: false,
          zopflipng: true,
          jpegRecompress: false,
          jpegoptim: true,
          mozjpeg: true,
          gifsicle: true,
          svgo: true
        },
        files: {
          'dist/img.png': 'src/img.png',
          'dist/img.jpg': 'src/img.jpg',
          'dist/img.gif': 'src/img.gif',
          'dist/img.svg': 'src/img.svg'
        }
      },
      dynamic: {
        files: [{
          expand: true,
          cwd: 'src/',
          src: ['**/*.{png,jpg,gif,svg}'],
          dest: 'dist/'
        }]
      }
    }
  });

  grunt.loadNpmTasks('grunt-image');
};

options attributes are optional. If you don't want to set as optimizer, set false. When you omitted, the optimizer will be applied.

Result