Skip to content

Instantly share code, notes, and snippets.

@nukos
Created April 7, 2015 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nukos/df02706d1ecbfd7287e4 to your computer and use it in GitHub Desktop.
Save nukos/df02706d1ecbfd7287e4 to your computer and use it in GitHub Desktop.
image resize task.
var gulp = require('gulp');
var filelog = require('gulp-filelog');
var glob = require('glob-all');
var imageResize = require('gulp-image-resize');
var paths = {
srcDir : 'source/articles'
}
gulp.task( 'image-optim:thumb', function(){
var image_dirs = glob.sync(['source/articles/**/images']);
var resizeOptions = {
width : 200,
height : 200,
gravity : 'Center',
crop : true,
upscale : false,
imageMagick : true
};
var imageminOptions = {
optimizationLevel: 7
};
for(var dir in image_dirs) {
var baseDir = image_dirs[dir];
var srcGlob = image_dirs[dir] + '/origin/*.+(jpg|jpeg|png|gif)';
var dstGlob = image_dirs[dir] + '/thumb';
gulp.src( srcGlob )
.pipe(filelog())
.pipe(imageResize( resizeOptions ))
.pipe(gulp.dest(dstGlob))
.pipe(filelog());
}
});
gulp.task( 'image-resize', ['image-optim:thumb'] );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment