Skip to content

Instantly share code, notes, and snippets.

@nukos nukos/gulpfile.js
Created Apr 7, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.