Need help with grunt-image?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

1000ch
199 Stars 21 Forks MIT License 303 Commits 14 Opened issues

Description

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

Services available

!
?

Need anything else?

Contributors list

# 39,491
imagemi...
vuejs
HTML
Electro...
204 commits
# 24,795
imagemi...
clean-c...
Svelte
Babel
3 commits
# 767,246
JavaScr...
grunt
1 commit
# 5,892
imagemi...
Babel
minify
exec
1 commit
# 6,915
JavaScr...
PureScr...
Vue.js
macOS
1 commit
# 275,247
Apache ...
jetson-...
webrtc
Ubuntu
1 commit

grunt-image GitHub Actions Status

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

Install

$ npm install --save-dev grunt-image

Usage

This is an example of

gruntfile.js
.
module.exports = function (grunt) {
  grunt.initConfig({
    image: {
      static: {
        options: {
          optipng: false,
          pngquant: true,
          zopflipng: true,
          jpegRecompress: false,
          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'); };

You can configure parameters applied to each optimizers such as following:

options: {
  optipng: ['-i 1', '-strip all', '-fix', '-o7', '-force'],
  pngquant: ['--speed=1', '--force', 256],
  zopflipng: ['-y', '--lossy_8bit', '--lossy_transparent'],
  jpegRecompress: ['--strip', '--quality', 'medium', '--min', 40, '--max', 80],
  mozjpeg: ['-optimize', '-progressive'],
  gifsicle: ['--optimize'],
  svgo: ['--enable', 'cleanupIDs', '--disable', 'convertColors']
}

Result

grunt-image result

License

MIT © Shogo Sensui

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.