Node.js: Error: Call ENOENT when using GM module
Even though this has been asked multiple times, none of the existing answers worked for me. Using MEAN environment (on Mac OSX) I installed graphicsmagick using:
sudo npm install gm
Whenever I run the following script, I get this error:
{ [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }
This is part of the code I'm trying to run:
var gm = require('gm');
//var gm = require('gm').subClass({ imageMagick: true }); //tried this one too
gm('./project/public/images/webshots/test1.jpg')
.resize(320, 240)
.write('./project/public/images/webshots/test2.jpg', function (err) {
if (!err) console.log('done');
if(err){
console.log(err);
}
});
Appropriate write permissions have been granted:
sudo chmod -R 777 ./project/public/images/webshots
I even tried several source / destination path combinations. What else could I have missed?
+3
source to share
3 answers
This helped me solve this problem.
gm('./project/public/images/webshots/test1.jpg')
.options({imageMagick: true})
.resize(320, 240)
.write('./project/public/images/webshots/test2.jpg', function (err) {
if (!err) console.log('done');
if(err){
console.log(err);
}
});
Note. imageMagick must be installed
+1
source to share