Skip to content

Instantly share code, notes, and snippets.

@justinemter
Created June 17, 2019 21:27
Show Gist options
  • Save justinemter/5ef4d57caa2da368dddff8790b49d6db to your computer and use it in GitHub Desktop.
Save justinemter/5ef4d57caa2da368dddff8790b49d6db to your computer and use it in GitHub Desktop.
Gulp file to resize / rename / optimize images for web.
var gulp = require('gulp');
var imageResize = require('gulp-image-resize');
var imagemin = require('gulp-imagemin');
var rename = require('gulp-rename');
gulp.task('default', function(callback) {
gulp.src('./**/*.jpg', { base: "./" })
.pipe(imageResize({
format: 'jpeg',
width: 2880,
imageMagick: false
}))
.pipe(imagemin({
progressive: true,
svgoPlugins: [{ removeViewBox: false }, { removeUselessStrokeAndFill: false }]
}))
.pipe(rename({
suffix: "-resized",
}))
.pipe(gulp.dest("."))
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment