ImageMagick after execution environment update

0

Is ImageMagick binary no longer included in the new execution environment or the Node.js 10.x runtime?

Current working environment: Node.js 6.10
Fails to work when a development alias is updated (times out at 60 seconds), but works again when the delay layer is added.
The same code bundle on a new deployment using Node.js 10.x runtime displays the message:
"Could not execute GraphicsMagick/ImageMagick: convert [COMMAND ARGS] this most likely means the gm/convert binaries can't be found"

I'm using the NPM package gm v1.23.1. Snippet below:

const gm = require('gm').subClass({ imageMagick: true })
let writeStream = fs.createWriteStream(pdfFile)
let convert = gm().command('convert')
for(let page of pages)
  convert.in(page)
convert.stream('pdf', (err, stdout, stderr) => {
  stdout.pipe(writeStream)
})

Edited by: aku-sch on Jul 1, 2019 5:07 PM

aku-sch
asked 5 years ago1073 views
6 Answers
0

Hi,

ImageMagick is no longer bundled with the Node.js 10.x runtime. There are two options to get ImageMagick working with your Node.js 10.x function:

  1. Package the dependency and include it in your uploaded ZIP file
    or
  2. Create or use a Lambda Layer that includes ImageMagick

Cheers,
Kevin

AWS
answered 5 years ago
0

Hi
I am new to all this Node stuff, what do you mean by "Package the dependency and include it in your uploaded ZIP file"? how can I do that? I am trying to use Node 10.x for image conversions using AWS Lambda. Please help!

Thanks

answered 4 years ago
0
answered 4 years ago
0

I ended up going through the process myself and it does indeed work.

To save you some time here's a zip file you can use to create a Lambda Layer.

https://connorb-share.s3.eu-west-2.amazonaws.com/image-magick.zip

When you create the layer make sure you add Node.js 10.x as a supported runtime. You can then set your function to use the latest Node.js 10.x and add the layer you created. The image conversion should then work again!

Edited by: connorB09b on Oct 20, 2019 5:20 AM

answered 4 years ago
0

Hi
Many thanks for this resource. We faced similar issue and used the zip file you provided and it worked. Can you please explain the process in creating the zip. We still have some issues with respect to image color and want to further investigate.

Thanks

answered 4 years ago
0

@connorB09b Thank you for posting your zip file, Connor!

Unfortunately, after we uploaded it as a new Lambda layer on our aws-lambda-image, it still didn't work for us.

This worked fine with NodeJS 8.10, but since we've been forced to upgrade (to either NodeJS 10.x or 12.x), it's not working even with the zip file.

I am familiar with layers, and I think i followed the instructions correctly. Can you think of anything further i need to do?

The Lambda is running in us-east-1 if that makes any difference.

Thanks!

answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions