当我尝试像这样调整图像大小时:
gm('public/uploads/1710410635.jpg')
.resize(240, 240)
.noProfile()
.write('public/uploads/1710410635_t.jpg', function (err) {
if (!err) console.log('done');
});我得到了这个错误:
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)我的文件结构如下:

代码在postnewsitem.js文件中执行
为什么会发生这个错误?我该如何解决它?
编辑: GraphicsMagick works,证明:

发布于 2013-10-08 23:44:41
安装imageMagick并使用subClass ImageMagick。
sudo apt-get install imagemagick
var gm = require('gm').subClass({ imageMagick: true });
发布于 2013-08-27 18:31:00
我在安装了gm和imagemagick的windows7上运行nodejs,似乎两个模块之间存在冲突,所以我用谷歌搜索了一下,找出了避免冲突的方法。我添加了下面这一行,这样就解决了我的环境问题:var imageMagick = gm.subClass({ imageMagick: true });,所以代码现在看起来像这样:
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);
})或者您可以在需要gm时这样做,如下所示:
var gm = require('gm').subClass({ imageMagick: true });发布于 2014-02-22 01:52:53
在使用IIS的Windows上运行的Node.js应用程序也有同样的问题。当我将相应AppPool的“高级设置”中的“Load User Profile”选项设置为"True“时,问题消失了。
https://stackoverflow.com/questions/16222116
复制相似问题