Search code snippets, questions, articles...

Compress images using Gulp

//Installation - npm install --save-dev gulp-imagemin
const gulp = require('gulp');
const imagemin = require('gulp-imagemin');
gulp.task('compress_img', function() {
    return gulp.src('src/images/*')
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

To compress images using gulp you can use gulp-imagemin npm package. The imagemin() function that is used to compress image will decrease the size of images.

NPM package installation

npm install --save-dev gulp-imagemin

You can also pass options that inside imagemin() function to make images compress as you want. The options can be:

    interlaced: true,
    progressive: true,
    optimizationLevel: 5,
    svgoPlugins: [
            removeViewBox: true
Was this helpful?