Node.js上的复合图像在本地工作但在heroku上失败

时间:2013-12-19 15:28:55

标签: heroku imagemagick graphicsmagick

我有一个像这样的复合图像代码:

// This method overlays the watermark on the source and save it as destination!
function compositeImage(source, watermark, destination, callback)
{
    var spawn = require('child_process').spawn;
    var composite = spawn('gm',
      [
          'composite',
          '-dissolve',
          '100', //溶解度,和透明度类似
          watermark,
          source,
          destination
      ]);

    composite.stdout.on('data',function(data){
      console.log(data);
    });

    composite.stderr.on('data',function(data){
      console.log(data);
    });

    composite.on('exit',function(code){
      if(code != 0){
          console.log('gm composite process exited with code ' + code);
      }
      callback();
    });
}

它在我的Mac上本地工作,但是当我尝试在Heroku上运行此方法时,我会收到如下错误:

UNCAUGHT ERROR: Error: spawn ENOENT
2013-12-19T15:27:17.708684+00:00 app[web.1]:     at errnoException (child_process.js:980:11)
2013-12-19T15:27:17.708684+00:00 app[web.1]:     at Process.ChildProcess._hand

1 个答案:

答案 0 :(得分:0)

您没有在Heroku上安装gm