-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.

4
  • 1
    Could you add a call to fs.stat() as shown here before you call im.resize(), and show the output? That will help us troubleshoot. Commented Oct 13, 2015 at 16:50
  • @NathanJones Thank you for your time. I just did that and File Exists was printed on my console. Commented Oct 13, 2015 at 16:54
  • 2
    If you open up a command line shell, can you run convert -version? According to this, you might not actually have imagemagick installed. Commented Oct 13, 2015 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. Commented Oct 13, 2015 at 18:17

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

If trying to call IM with the github.com/aheckmann/gm module on Windows, I also had to check "Install legacy utilities (e.g. convert)" in the install wizard.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.