I'm writing an application to leverage this library into a general purpose image resizing utility
Have it working with local files, attempting to update it with http streams.
Looks like in theory its resize
wrapper will take a srcData
object, which I assume can be a Buffer object, but my app is choking.
Here's a simplified version:
im = require('imagemagick')
request = require('request')
sampleImage = "http://www.ibm.com/developerworks/data/library/techarticle/dm-0504stolze/test_1.jpg"
request.get(sampleImage, (err, res, body) ->
taskHash = {
srcPath: "-"
srcData: body
dstPath: "-"
height: 100
}
callback = (err, stdout, stderr)->
if err
console.error(err)
process.exit(1)
console.log(stdout)
im.resize(taskHash, callback)
)
This is erroring out:
{ [Error: Command failed: convert: no decode delegate for this image format `/var/tmp/magick-37627o1E7kWz7yGaf' @ error/constitute.c/ReadImage/555.
convert: no images defined `-' @ error/convert.c/ConvertImageCommand/3144.
] timedOut: false, killed: false, code: 1, signal: null }
which makes me think that it's having trouble identifying the Buffer as a a jpg object. But even if I explicitly declare the buffer as a jpg in the options hash, it still gives me the same error:
taskHash = {
srcPath: "-"
srcData: body
dstPath: "-"
format: 'jpg'
height: 100
}
Not sure how to pass this in as a correct Buffer object.