问题
I am trying to create a thumbnail with an image that I have already saved. I am using the module gm
to adjust the size of the image.
var gm = require ('gm');
var fs = require('fs');
var savedphoto = "./testphoto.jpeg";
var testdir = "./testoutput.jpeg";
gm(savedphoto)
.resize(100, 100)
.noProfile()
.write(testdir, function (err) {
console.error (err);
});
When I run this I get the error spawn ENOENT
.
code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn.
How would I fix this problem?
回答1:
Replace:
var gm = require('gm');
for
var gm = require('gm').subClass({ imageMagick: true });
回答2:
Recipe for MacPorts users only (based on @RevNoah notice):
sudo port install GraphicsMagick
It will install GraphicsMagick library.
来源:https://stackoverflow.com/questions/22930506/nodejs-error-spawn-enoent-while-adjusting-image-size-using-module-gm