我正在尝试使用无损优化 JPEG / PNG 图像imagemin
,但是在使用扩展时我遇到了一个问题,它们“去优化”,这意味着结果图像比原始图像大。我怎样才能防止这种情况?
这是我的Gruntfile.js
...
grunt.initConfig({
imagemin: {
jpeg: {
options: {
//by default it uses imageminJpegtran
progressive: true,//default false, progressive JPEG is better compression https://superuser.com/questions/463477/progressive-jpeg-quality-compare-to-normal-jpeg
arithmetic: false,//true breaks image
//don't know how to use it loseless without making the images even bigger
// use: [
// imageminMozjpeg({
// quality: 95, //Compression quality, in range 0 (worst) to 100 (perfect).
// dcScanOpt: 2,//2 Optimize between one scan for all components and one scan for 1st component plus one scan for remaining components
// arithmetic: false// false, or it breaks the image
// }),
// ],
},
files: [{
expand: true,
cwd: '/www',
src: ['**/*.{jpg,jpeg,JPG,JPEG}'],
dest: '/www',
filter: 'isFile'
}]
}
}
});
...