Gulp Imagemin Versions Save

Minify PNG, JPEG, GIF and SVG images


3 years ago


  • Require Node.js 10 aacca91
  • Replace jpegtran with mozjpeg in the default plugins (#336) 279a91b


3 years ago


3 years ago
  • Make Gulp an optional peer dependency 165bf8b


3 years ago


3 years ago


6 years ago

Previously, the options you passed in each applied to different bundled plugins. This was confusing for many users. Now you explicitly pass options directly to the plugins you use. By default, this module comes bundled with 4 imagemin plugins with good defaults. Most should not need to change anything. If you do need to pass some options or use other plugins, you can pass in an array of plugins with options in the use argument, overriding the defaults.

Here's how you would transition the different options:

 gulp.task('default', () => {
    return gulp.src('src/images/*')
-       .pipe(imagemin({
-           interlaced: true,
-           progressive: true,
-           optimizationLevel: 5,
-           svgoPlugins: [{removeViewBox: false}]
-       }))
+       .pipe(imagemin([
+           imagemin.gifsicle({interlaced: true}),
+           imagemin.jpegtran({progressive: true}),
+           imagemin.optipng({optimizationLevel: 5}),
+           imagemin.svgo({plugins: [{removeViewBox: false}]})
+       ]))

Note that if you pass in an array of plugins you need to explicitly pass in every plugin you want, not just the ones you want to change options for.