javascriptnode.jsimagemagicknode-imagemagick

Image Magick Module throwing weird error (Express js Node js)


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.


Solution

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