1

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);
      })
  });
};
tuck
  • 603
  • 5
  • 13

1 Answers1

1

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

tuck
  • 603
  • 5
  • 13