Error: spawn ENOENT while using GM in node

Olivier_s_j picture Olivier_s_j · Apr 25, 2013 · Viewed 32.1k times · Source

When I try to resize an image like this:

                gm('public/uploads/1710410635.jpg')
                .resize(240, 240)
                .noProfile()
                .write('public/uploads/1710410635_t.jpg', function (err) {
                  if (!err) console.log('done');
                });

I get this error:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:945:11)
    at Process.ChildProcess._handle.onexit (child_process.js:736:34)

My file structure is as follows:

enter image description here

The code is executed in the postnewsitem.js file

why is this error occurring & how do I solve it ?

edit: GraphicsMagick works, proof:

enter image description here

Answer

Quỳnh Lê picture Quỳnh Lê · Oct 8, 2013

Install ImageMagick and use subClass imageMagick.

  1. Install ImageMagick

    sudo apt-get install imagemagick
    
  2. using subClass imagemagick:

    var gm = require('gm').subClass({ imageMagick: true });