简体   繁体   中英

Grunt Imagemin not compressing jpgs

My imagemin doesn't seem to compress jpgs? It says: "37 images found. Saved 0 B.

Weirdly enough it works on .gif and .png so I know it's working to some degree. Anyone else had this problem?

I've tried uninstalling/re-installing. Also got the latest version: 0.9.4.

Here's my code:

imagemin: {
  dynamic: {
    options: {
      optimizationLevel: 3
    },
    files: [{
      expand: true,
      cwd: 'imgs-src/',
      src: ['**/*.{png,jpg,gif}'],
      dest: 'imgs/'
    }]
  }
}

Thanks!

As per the plugin documentation,Options will only apply to the relevant files within your src.

The option that you provided is optimizationLevel and its value 3, Which is applicable for only png images and not for other formats.

optimizationLevel (png)

progressive (jpg)

interlaced (gif)

svgoPlugins (svg)

you need to use

progressive:true

within your code for enabling compression of jpgs.

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