Skip to content
Optimize PNG, JPEG, GIF, SVG images with gulp task.
JavaScript
Find file
Latest commit 987cf8f @1000ch 1.3.1
Failed to load latest commit information.
screenshot add a screenshot
test change fixures for test
.editorconfig add editorconfig
.gitignore initial commit
.travis.yml test with stable
index.js change default settings
optimizer.js fix style
package.json 1.3.1
readme.md Fix svgo execution (had wrong cwd).
round10.js update

readme.md

gulp-image

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

Build Status NPM version Dependency Status devDependency Status Analytics

Install

$ npm install --save-dev gulp-image

Usage

This is an example of gulpfile.js.

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

gulp.task('image', function () {
  gulp.src('./fixtures/*')
    .pipe(image())
    .pipe(gulp.dest('./dest'));
});

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

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

gulp.task('image', function () {
  gulp.src('./fixtures/*')
    .pipe(image({
      pngquant: true,
      optipng: false,
      zopflipng: true,
      advpng: true,
      jpegRecompress: false,
      jpegoptim: true,
      mozjpeg: true,
      gifsicle: true,
      svgo: true
    }))
    .pipe(gulp.dest('./dest'));
});

Set false if you don't want to apply.

Optionally you may pass enable and disable options to svgo:

gulp.task('image', function () {
  gulp.src('./fixtures/*')
    .pipe(image({
      svgo: { enable: ["removeRasterImages"], disable: ["removeDoctype"] }
    }))
    .pipe(gulp.dest('./dest'));
});

License

MIT: http://1000ch.mit-license.org/

Something went wrong with that request. Please try again.