-
-
Save zreese/619383a80903b850d933e4c7aa171072 to your computer and use it in GitHub Desktop.
best image compression settings (gulp-imagemin)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// install | |
// npm i gulp-imagemin imagemin-jpeg-recompress imagemin-pngquant imagemin-zopfli imagemin-mozjpeg -f | |
var imagemin = require('gulp-imagemin'); | |
var imageminPngquant = require('imagemin-pngquant'); | |
var imageminZopfli = require('imagemin-zopfli'); | |
var imageminMozjpeg = require('imagemin-mozjpeg'); //need to run 'brew install libpng' | |
var imageminJpegRecompress = require('imagemin-jpeg-recompress'); | |
gulp.task('imagemin', function() { | |
return gulp.src(['src/**/*.{png,jpg}']) | |
.pipe(imagemin([ | |
//png | |
imageminPngquant({ | |
speed: 1, | |
quality: 98 //lossy settings | |
}), | |
imageminZopfli({ | |
more: true | |
}), | |
//jpg lossless | |
imagemin.jpegtran({ | |
progressive: true | |
}), | |
imageminJpegRecompress({ | |
loops:6, | |
min: 40, | |
max: 85, | |
quality:'low' | |
}), | |
//jpg very light lossy, use vs jpegtran | |
imageminMozjpeg({ | |
quality: 90 | |
}) | |
])) | |
.pipe(gulp.dest('dist')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment