I'm using nodejs and graphicsmagick to process images with text, then streaming the final jpg to S3.
Using postman, I was able to test this flow on my localhost and everything works fine. However, I'm having issues now that I moved it to Elastic Beanstalk. When I post to the endpoint, it uploads a blank file to S3 and there are no errors logged in EB. I think it has something to do with the software but am a bit stuck. Any advice appreciated! Thanks!
Top file is from localhost, bottom file is from Elastic Beanstalk: http://cl.ly/image/0O231k171N0W
var gm = require('gm'); var appRoot = require('app-root-path').path; function createImage(caption, res) { var originalImage = '/images/2015-02-24.jpg'; var textColor = 'white'; gm(appRoot + originalImage) .fill(textColor) .font( appRoot + '/fonts/BentonSans-Book.otf') .drawText(0, 0, caption, 'Center') .stream(function(err, stdout, stderr) { sendToS3(err, stdout, stderr, originalImage, res); }); } function sendToS3(err, stdout, stderr, originalImage, client_response) { var imageName = shortId.generate(); var buff = new Buffer(''); stdout.on('data', function(data) { buff = Buffer.concat([buff, data]); }); stdout.on('end', function(data) { var data = { Bucket: S3_bucket, Key: imageName + '.jpg', Body: buff, ContentType: mime.lookup(originalImage) }; s3.putObject(data, function(err, res) { client_response.send('done'); }); }); }
===============================================================
EDIT: Instead of streaming to S3, I changed it to write directly to the filesystem. The error being thrown in AWS EB logs is:
err { [Error: Command failed: gm convert: Request did not return an image.] code: 1, signal: null }
I believe I'm missing some dependencies for ImageMagick. Any thoughts?
This is from running convert --version in my local terminal:
Version: ImageMagick 6.8.9-7 Q16 x86_64 2014-08-31 http://www.imagemagick.org Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC Features: DPC Modules Delegates: bzlib freetype jng jpeg ltdl lzma png xml zlib
This is from running convert --version in my EC2 instance (The Delegates section is empty):
Version: ImageMagick 6.9.1-1 Q16 x86_64 2015-04-10 http://www.imagemagick.org Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC License: http://www.imagemagick.org/script/license.php Features: DPC OpenMP Delegates (built-in):