gm流标准输出管道抛出未处理的错误 [英] gm stream stdout pipe throwing unhandled error

查看:91
本文介绍了gm流标准输出管道抛出未处理的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取图像URL,然后获取图像,然后将其写入文件系统,然后调整其大小.调整大小结束时,我想将其返回给响应,以便客户端获取图像.现在stdout.pipe(res)没有返回,并且我得到一个events.js:72错误:throw er; //未处理的错误"事件.

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.

我缺少明显的东西吗?

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);
      })
  });
};

推荐答案

原来,我没有在该实例上安装GraphicsMagick.安装后,它会按预期运行.

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

这篇关于gm流标准输出管道抛出未处理的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆