Answer the question
In order to leave comments, you need to log in
How to properly set up gulp-image-resize?
I want to run a lot of pictures through gulp. Those of them that are larger than 2000x2000 pixels should be reduced to this size.
windows 10x64 I
include gulp-image-resize (pre-installed imagemagick and GraphicsMagick )
the task itself
gulp.task('imgresize', function () {
return gulp.src('src/img/')
.pipe(imageresize({
width : 100,
height : 100,
crop : true,
upscale : false
}))
.pipe(gulp.dest('build/img/'));
});
gulp.src("src/img/*.*")
[16:28:27] Starting 'imgresize'...
events.js:85
throw er; // Unhandled 'error' event
^
Error: Error: write EPIPE
at finish (d:\html\working\arplan\node_modules\gulp-image-resize\node_modules\gulp-gm\index.js:40:21)
at gm.<anonymous> (d:\html\working\arplan\node_modules\gulp-image-resize\node_modules\async\lib\async.js:485:30)
at gm.emit (events.js:118:17)
at gm.<anonymous> (d:\html\working\arplan\node_modules\gulp-image-resize\node_modules\gulp-gm\node_modules\gm\lib\getters.js:70:16)
at Socket.cb (d:\html\working\arplan\node_modules\gulp-image-resize\node_modules\gulp-gm\node_modules\gm\lib\command.js:318:16)
at Socket.g (events.js:199:16)
at Socket.emit (events.js:107:17)
at onwriteError (_stream_writable.js:317:10)
at onwrite (_stream_writable.js:335:5)
at WritableState.onwrite (_stream_writable.js:105:5)
Answer the question
In order to leave comments, you need to log in
1. Change return gulp.src('src/img/')
to return gulp.src('src/img/**/*.{jpg,png}'))
2. Try using imageMagick, not GraphicsMagick (imageMagick: true)
3. Optionally add optimizations with gulp-changed
var changed = require("gulp-changed");
gulp.task('imgresize', function () {
return gulp.src('src/img/')
.pipe(changed("build"))
.pipe(imageresize({
width : 100,
height : 100,
crop : true,
upscale : false
}))
.pipe(gulp.dest('build/img/'));
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question