Skip to content

Instantly share code, notes, and snippets.

@Blake-C
Last active July 16, 2018 03:01
Show Gist options
  • Save Blake-C/6529985ec51d187d2270bacaced852b9 to your computer and use it in GitHub Desktop.
Save Blake-C/6529985ec51d187d2270bacaced852b9 to your computer and use it in GitHub Desktop.
Gulp image resize task
// https://www.npmjs.com/package/gulp-gm
// https://www.npmjs.com/package/gulp-newer
gulp.task('images', () => {
return gulp.src( `${dir.theme_components}/images/**/*` )
.pipe( $.newer( `${dir.assets}/images` ) )
.pipe( $.gm( gmfile => {
return gmfile.resize( 1300, 1300 );
}))
.pipe( $.imagemin({
progressive: true,
interlaced: true,
svgoPlugins: [{
// don't remove IDs from SVGs, they are often used
// as hooks for embedding and styling
cleanupIDs: false
}],
use: [
$.imageminPngquant({
quality: '65-80',
speed: 4
})
],
}).on( 'error', () => {
this.end();
}))
.pipe( gulp.dest(`${dir.assets}/images`) );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment