gm stream stdout pipe throwing unhandled error

烂漫一生 提交于 2019-12-23 04:05:07

问题


I am trying to take an image url get the image then write it to the filesystem then resize it. At the end of the resizing I would like to return it back to the response so the client gets the image. Right now the stdout.pipe(res) is not returning and I get an events.js:72 error: throw er; // Unhandled 'error' event.

Am I missing anything obvious?

exports.getImage = function(req, res, next) {
  var fileId = Math.uuid();

  var i = request.get(req.params.image).pipe(fs.createWriteStream(fileId));
  i.on('close', function () {

    gm(fileId)
      .resize('200', '200')
      .stream(function (err, stdout, stderr) {
        if (err) next(err);
        stdout.pipe(res);
      })
  });
};

回答1:


Turns out I did not have GraphicsMagick installed on this instance. When installed it worked like I expected.



来源:https://stackoverflow.com/questions/21893645/gm-stream-stdout-pipe-throwing-unhandled-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!