Search code examples
node.jsaws-lambdagraphicsmagick

AWS Lambda GraphicsMagick error: gm/convert binaries can't be found"


I'm suing GraphicsMagick in a Lambda function with Node and I'm getting this error:

Could not execute GraphicsMagick/ImageMagick: gm "convert" "/tmp/yH3Js6ALXVGGAokvIsij.png" "/tmp/a086ffd7-a143-4f83-8f6a-fcdd29b12630.png" this most likely means the gm/convert binaries can't be found
at ChildProcess.<anonymous> (/var/task/node_modules/gm/lib/command.js:232:12)
at emitOne (events.js:96:13)
at ChildProcess.emit (events.js:188:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:213:12)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)

So it says the gm/convert binaries can't be found which means the app isn't installed although the line "gm": "^1.23.1" is in package.json. Can you tell me now I can include the gm/convert binaires in the repo to make it work? Thank you!


Solution

  • gm is a NodeJS package for using ImageMagick. You still need ImageMagick itself.

    You would need to install and compile ImageMagick for the Lambda environment. You can then upload it as a Lambda layer where your Lambda Function can sit on top of.

    If you use serverless, you can take a look at this answer that provides you the steps on how to build ImageMagick as a Lambda layer.