4

I get an error as follows when calling resize:images task in my gulpfile (see bottom) ...

events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: Error: write EOF
    at finish (C:\Users\brendan\Documents\Code\Web\TheOrm\WWW\v3\node_modules\gulp-gm\index.js:40:21)
    at gm.<anonymous> (C:\Users\brendan\Documents\Code\Web\TheOrm\WWW\v3\node_modules\async\lib\async.js:485:30)
    at emitMany (events.js:127:13)
    at gm.emit (events.js:201:7)
    at gm.<anonymous> (C:\Users\brendan\Documents\Code\Web\TheOrm\WWW\v3\node_modules\gm\lib\getters.js:70:16)
    at Socket.cb (C:\Users\brendan\Documents\Code\Web\TheOrm\WWW\v3\node_modules\gm\lib\command.js:322:16)
    at Socket.g (events.js:291:16)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at onwriteError (_stream_writable.js:340:10)

Imagemagick is installed and seems to work from the command line. i.e. magick -help gives sensible output and you can save the inbuilt test logo image.

I have tried various other gulp libraries including gulp-responsive-images which gives an empty pipe error.

I tried this under the Linux Subsystem for Windows and it works fine - it seems that this is a Windows only problem.

After forking gulp-image-resize and running the test suite I get the following error ...

...
[14:18:20] Starting 'image_resize:interlace_and_resize_imagemagick'...
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at exports._errnoException (util.js:1026:11)
    at Socket._writeGeneric (net.js:710:26)
    at Socket._write (net.js:729:8)
    at doWrite (_stream_writable.js:328:12)
    at writeOrBuffer (_stream_writable.js:314:5)
    at Socket.Writable.write (_stream_writable.js:241:11)
    at Socket.write (net.js:656:40)
    at gm._spawn (C:\Users\brendan\Documents\Code\OpenSource\gulp-image-resize\node_modules\gm\lib\command.js:194:18)
    at gm._exec (C:\Users\brendan\Documents\Code\OpenSource\gulp-image-resize\node_modules\gm\lib\command.js:167:17)
    at gm.proto.(anonymous function) [as size] (C:\Users\brendan\Documents\Code\OpenSource\gulp-image-resize\node_modules\gm\lib\getters.js:68:12)

Unfortunately, the repo had bug reporting disabled - does anyone know how this might be remedied?

Here is my gulpfile.js ...

let gulp = require('gulp');
let imageResize = require('gulp-image-resize');
let path = require('path');
let rename = require('gulp-rename');
let debug = require('gulp-debug');

let INPUT_DIR = './NO_UPLOAD/img_src';
let OUTPUT_DIR = './NO_UPLOAD/img_tmp';

gulp.task('resize:images', function() {
    relFns = [
        'logo.png',
        'image.png',
        ].map((f) => path.join(INPUT_DIR, f));
    return gulp.src(relFns, { base: INPUT_DIR })
        .pipe(debug({ title: 'resized' }))
        .pipe(imageResize({
            width: 100
        }))
        .pipe(rename((path) => { path.basename += '.sml'  }))
        .pipe(gulp.dest(OUTPUT_DIR));
});
Brendan
  • 18,771
  • 17
  • 83
  • 114

1 Answers1

10

There were a number of issues ...

  1. Make sure Graphicsmagick is installed as well (may not be necessary but did not do any harm to install)
  2. make sure both gm and magick are in your path
  3. After referring to a comment on this post, I found restarting the computer fixed the issue. (I was surprised at the restart since opening up a new console usually works.)
  4. Finally make sure that you don't run from a console opened from Visual Studio Code instance. VSCode is a 32bit app and launches a 32bit console which does not run 64bit versions of Imagemagick. Instead launch the console from Explorer.
Community
  • 1
  • 1
Brendan
  • 18,771
  • 17
  • 83
  • 114
  • Good point! But it seems to access `convert.exe` which is also part of Windows NT file system converter. Set the magick path before `C:\Windows\system32` like: `PATH c:\Program Files (x86)\ImageMagick-6.7.6-Q8;%PATH%` – kenjiuno Jul 24 '17 at 05:37
  • 1
    I was running gulp from VSCode! Executing from Powershell solved the issue – Lino Bossio Jun 03 '18 at 05:07