ImageMagick in functions

Is it possible to use ImageMagick in a Netlify function?

Hey @cbetta_box, I believe the answer is no, partly due to the 50MB limit for a zipped function:

But you may want to follow that thread and/or chime in?

Not sure if that answers my question. I am basically trying to use a Netlify function to generate an image and return it. Not sure if that’s doable.

This topic might provide some insight: Question about storage and rate limits on node.js based Netlify functions - #8 by coronatimemap.com

You might be better off trying to process your images with the build pipeline but as image processing takes a lot of time (or too much time if you have a lot of images) I’d recommend Netlify Large Media or external image processing services.

@cbetta_box i actually spent quite extensive amount of time 2 weeks ago on getting node’s gm module work with graphicmagick on Netlify, it didn’t work because without the Lambda Layers (which set up binary outside of your function directory), Imagemagick binary may take too much size beyond 50mb size limit for each Lambda function’s content.

My solution was to change to using Go and Netlify functions, the development flow is a little worse since it’s not supported natively by Nelitfy-cli dev, but Golang has very strong image package come bundled so if you can code in Golang you can probably do some simple image tasks and make it work.(The resulting binary for my Golang-based solution was just ~10mb, way smaller than 100mb for node-canvas and graphicmagick)

2 Likes

Excellent. Do you happen to have the code for this somewhere?