黄舟2017-04-17 13:15:15
Of course it cannot be suppressed by using default components and default parameters. Imagemin has to match the components and parameters by itself. . .
Post paragraph written by myself:
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(srcImage)
.pipe(imagemin({
use: [jpgmin, pngmin]
}))
.pipe(gulp.dest(dstImage));
});
The effect of compressing jpeg and png is good, but other formats have never been accessible, so I use the default processing.
For tool software, I currently use Antelope. Just drag the file in and click Optimize.
巴扎黑2017-04-17 13:15:15
http://www.atool.org/pngcompression.php I made it myself, supports jpg png, the effect is absolutely awesome...
PHP中文网2017-04-17 13:15:15
I used this plug-in https://www.npmjs.com/package/gulp-tinypng-compress
The advantage is that the compression effect is very good and the image quality is guaranteed because https://tinypng is used. com his api.
The disadvantage is that it takes a long time and there is a monthly quantity limit
高洛峰2017-04-17 13:15:15
There is no imagemin module in npm. I personally like to use gulp;
can refer to the official demo. If you use the official demo, please change const
to var
. const
is es6 syntax.
const gulp = require('gulp');
const imagemin = require('gulp-imagemin');
const pngquant = require('imagemin-pngquant');
gulp.task('default', () => {
return gulp.src('src/images/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('dist/images'));
});