search

Home  >  Q&A  >  body text

node.js - 利用gulp-imagemin压缩jpg格式图片变化不大

使用gulp-imagemin压缩图片,对于png图,压缩前后变化还是挺明显的,但是压缩jpg图片变化很小,gulpfile的设置如下:

const gulp = require('gulp');
const imagemin = require('gulp-imagemin');
const imageminPngquant = require('imagemin-pngquant');
const imageminJpegtran = require('imagemin-jpegtran');
 
gulp.task('default', () =>
    gulp.src('src/images/*')
        .pipe(imagemin({
            use:[imageminPngquant(),imageminJpegtran()]
        }))
        .pipe(gulp.dest('dist/images'))
);

如何让压缩的jpg也像png图一样压缩前后大小变化比较明显?

迷茫迷茫2780 days ago746

reply all(2)I'll reply

  • PHPz

    PHPz2017-04-17 14:49:53

    gulp.task('imgmin', function () {
        var jpgmin = imageminJpegRecompress({
                accurate: true,//高精度模式
                quality: "high",//图像质量:low, medium, high and veryhigh;
                method: "smallfry",//网格优化:mpe, ssim, ms-ssim and smallfry;
                min: 70,//最低质量
                loops: 0,//循环尝试次数, 默认为6;
                progressive: false,//基线优化
                subsample: "default"//子采样:default, disable;
            }),
            pngmin = imageminOptipng({
                optimizationLevel: 4
            });
        gulp.src("src/img/*.*")
            .pipe(imagemin({
                use: [jpgmin, pngmin]
            }))
            .pipe(gulp.dest("dist/img"));
    });

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 14:49:53

    Have you solved the problem? I feel that the compression speed is very slow. Is there any way to speed up the compression?

    reply
    0
  • Cancelreply