简体   繁体   中英

Are there levels of compression for Grunt imagemin?

I have the plugin working and it does some optimization but it seems minimal compared to other tools. For example, using Shrink O'matic I can control the amount of optimization and get really small jpgs (original ~ 2.4 MB and new ~ 25KB) while imagemin gets the original down to like 2MB.

Is there some way to get imagemin to compress further for images that don't really need to be all that high def?

You will need to utilize additional plugins using the use option in grunt-contrib-imagemin. A list of supported plugins can be found at https://www.npmjs.com/browse/keyword/imageminplugin

An example Grunt task configuration for imagemin-mozjpeg plugin would be like (configuration for different plugins would vary according to the options it provides) -

imagemin: {
  dist: {
    files: [{
      expand: true,
      src: '*.{png,svg,jpg,jpeg,gif}',
      dest: 'images'
    }],
    options: {
      use: [
          imageminMozjpeg({quality: 20})
      ]
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM