I'm changing my code to fetch a remote image from an http get instead of an s3 object and having some trouble with the data. The data is not null and does seem to be an image binary - but am I sending in the wrong stream format or something - or sending an invalid format into the graphicsmagick constructor?
I get the error
{ [Error: Command failed: identify: unable to open image `����': No such file or directory @ error/blob.c/OpenBlob/2701.
identify: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501.
] code: 1, signal: null }
With the code below
var request = require('request');
var gm = require('gm').subClass({imageMagick: true}); // Enable ImageMagick integration.
var imageType = require('image-type');
request('http://c3.diapers.com/images/products/p/PG/PG-418_1z.jpg', function(error, response, body) {
if (error) {
console.error('unable to download image ' + err);
return res.status(404).send('unable to download image ' + err);
}
if (!body)
return res.status(404).send('no body response for image');
var original = gm(body);
original.size(function (err, size) {
if (err) {
console.error(err);
return res.status(500).send(err);
}
resize_photo(size, targetSize, original, function (err, photo) {
res.setHeader('Content-Type', 'image/jpeg');
res.send(photo);
});
});
});