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:
The code is executed in the postnewsitem.js
file
why is this error occurring & how do I solve it ?
edit: GraphicsMagick works, proof:
Install ImageMagick and use subClass imageMagick.
Install ImageMagick
sudo apt-get install imagemagick
using subClass imagemagick:
var gm = require('gm').subClass({ imageMagick: true });
I'm running nodejs on windows 7 with installed gm and imagemagick and seems that there was conflict between both modules so i googled a bit and found out how to avoit that. I added this line and that solved my ENOENT problem:
var imageMagick = gm.subClass({ imageMagick: true });
so the code now looks like this:
var gm = require('gm');
var imageMagick = gm.subClass({ imageMagick: true });
imageMagick('test/pig.jpg').rotate('green', 45).write('test/crazy_pig.jpg', function (err) {
if (!err) console.log('crazy pig has arrived');
else console.log(err);
})
OR you can do that when requiring gm, like so:
var gm = require('gm').subClass({ imageMagick: true });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With