-2

Please look at the code first. Here I am taking a series of input and name of photos are in a array format.

for (var i = 0; i < photos.length; i++) {
var x = './images/offers/' + testooo + '/' + photos[i];
var y = './images/offers/' + testooo + '/thumbnails/' + photos[i];
/*
gm(x)
.resizeExact(200, 200)
.write(y, function (err) {
  if (!err) console.log('done');
});*/

im.resize({

    srcData: fs.readFileSync(x, 'binary'),
    width: 200
}, function(err, stdout, stderr) {
    if (err) {

        console.log(err);
        console.log('error part');
    }
    fs.writeFileSync(y, stdout, 'binary');
    console.log('Resized Photos');
});
}

You can see that image magick part is there which throws this error.

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: write EOF
    at exports._errnoException (util.js:746:11)
    at WriteWrap.afterWrite (net.js:775:14)

Now one thing more I'd like to add you can see that in commented part there is something starting with gm literals. I tried using graphics magick module as well. The code runs without any error but no thumb nails are created. Graphics Magick module works using image magick module.

Please let me know what am I doing wrong.

Gandalf the White
  • 2,415
  • 2
  • 18
  • 39
  • 1
    Could you add a call to `fs.stat()` as shown [here](http://stackoverflow.com/a/17699926/690573) before you call `im.resize()`, and show the output? That will help us troubleshoot. – Nathan Jones Oct 13 '15 at 16:50
  • @NathanJones Thank you for your time. I just did that and File Exists was printed on my console. – Gandalf the White Oct 13 '15 at 16:54
  • 2
    If you open up a command line shell, can you run `convert -version`? According to [this](http://stackoverflow.com/a/21871588/690573), you might not actually have imagemagick installed. – Nathan Jones Oct 13 '15 at 17:14
  • @NathanJones Thank you. The problem was exactly the same but only one image from the array of urls is getting re-sized. Anyway that is a different problem, I'll look into it. Thanks for your help. Please post the same thing as answer, that'll help others facing similar problem. – Gandalf the White Oct 13 '15 at 18:17

1 Answers1

3

This error can be caused by ImageMagick not being installed.

If you cannot run convert -version and see ImageMagick version details in a shell, you probably haven't installed it.

The installer can be found here.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Nathan Jones
  • 4,904
  • 9
  • 44
  • 70
  • If trying to call IM with the https://github.com/aheckmann/gm module on Windows, I also had to check "Install legacy utilities (e.g. convert)" in the install wizard. – James Irwin Dec 31 '19 at 16:27