Awesome Open Source
Awesome Open Source

gulp-image GitHub Actions Status

Optimize PNG, JPEG, GIF, SVG images with gulp task.

gulp-image result


$ npm install --save-dev gulp-image

External Dendencies

  • brew install libjpeg libpng on macOS
  • apt-get install -y libjpeg libpng on Ubuntu
  • npm install -g windows-build-tools on Windows


This is an example of gulpfile.js.

const gulp = require('gulp');
const image = require('gulp-image');

gulp.task('image', function () {

gulp.task('default', ['image']);

You can pass an object to image() as argument such as following:

gulp.task('image', () => {
      pngquant: true,
      optipng: false,
      zopflipng: true,
      jpegRecompress: false,
      mozjpeg: true,
      gifsicle: true,
      svgo: true,
      concurrent: 10,
      quiet: true // defaults to false

Set false for optimizers which you don't want to apply. And you can set concurrent option to limit the max concurrency in execution. You can also set quiet to avoid logging out results for every image processed.

You can configure parameters applied to each optimizers such as following:

gulp.task('image', () => {
      optipng: ['-i 1', '-strip all', '-fix', '-o7', '-force'],
      pngquant: ['--speed=1', '--force', 256],
      zopflipng: ['-y', '--lossy_8bit', '--lossy_transparent'],
      jpegRecompress: ['--strip', '--quality', 'medium', '--min', 40, '--max', 80],
      mozjpeg: ['-optimize', '-progressive'],
      gifsicle: ['--optimize'],
      svgo: ['--enable', 'cleanupIDs', '--disable', 'convertColors']


MIT Shogo Sensui

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,537,680
Image (4,637
Gulp (2,728
Optimization (2,428
Gif (813
Png (736
Jpeg (408
Related Projects