Created
April 7, 2015 00:54
-
-
Save nukos/df02706d1ecbfd7287e4 to your computer and use it in GitHub Desktop.
image resize task.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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