gulp-is-images

2.0.4 • Public • Published

gulp-is-images

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

Install

$ yarn add -D gulp-is-images

External Dendencies

  • brew install libjpeg libpng on macOS
  • apt-get install -y libjpeg libpng on Ubuntu

Usage

This is an example of gulpfile.js.

const gulp = require('gulp');
const images = require('gulp-is-images');
 
gulp.task('images', function () {
  gulp.src('src/images/**/*')
    .pipe(images())
    .pipe(gulp.dest('dist/images/'));
});
 
gulp.task('default', ['images']);

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

gulp.task('images', function () {
  gulp.src('src/images/**/*')
    .pipe(images({
      pngquant: true,
      optipng: false,
      zopflipng: true,
      jpegRecompress: false,
      jpegoptim: true,
      mozjpeg: true,
      gifsicle: true,
      svgo: true,
      concurrent: 10
    }))
    .pipe(gulp.dest('dist/images/'));
});

Set false for optimizers which you don't want to apply. And you can set concurrent option to limit the max concurrency in execution.

Optionally you may pass enable and disable options to svgo:

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

Readme

Keywords

none

Package Sidebar

Install

npm i gulp-is-images

Weekly Downloads

0

Version

2.0.4

License

MIT

Last publish

Collaborators

  • jameelmoses