Grunt Imagemin not compressing jpgs

299 Views Asked by At

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!

1

There are 1 best solutions below

1
On

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.