gulp-is-images
v2.0.4
Published
Optimize PNG, JPG, GIF, SVG images with gulp task.
Downloads
2
Readme
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 macOSapt-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/**/*'));
});