ImageMagick for AWS Lambda 2 runtimes
Scripts to compile ImageMagick utilities for AWS Lambda instances powered by Amazon Linux 2.x, such as the
python 3.8runtime, and the updated 2018.03 Amazon Linux 1 runtimes.
Amazon Linux 2 instances for Lambda no longer contain system utilities, so
identifyfrom the ImageMagick package are no longer available.
Absolutely the easiest way of using this is to pull it directly from the AWS Serverless Application repository into a CloudFormation/SAM application, or deploy directly from the Serverless Application Repository into your account, and then link as a layer.
For more information, check out the image-magick-lambda-layer application in the Serverless App Repository.
For manual deployments and custom builds, read below...
There are two
makescripts in this project.
Makefileis intended to run on the build system, and just starts a Docker container matching the AWS Linux 2 environment for Lambda runtimes to compile ImageMagick using the second script.
Makefile_ImageMagickis the script that will run inside the container, and actually compile binaries.
The output will be in the
By default, this compiles a version expecting to run as a Lambda layer from
/opt. You can change the expected location by providing a
TARGETvariable when invoking
The default Docker image used is
lambci/lambda-base-2:build. To use a different base, provide a
DOCKER_IMAGEvariable when invoking
make bashto open an interactive shell with all the build directories mounted
make libsto make only the libraries, useful to test building additional libraries without building ImageMagick itself
This is not a full-blown ImageMagick setup you can expect on a regular Linux box, it's a slimmed down version to save space that works with the most common formats. You can add more formats by including another library into the build process in
These libraries are currently bundled:
Run the following command to deploy the compiled result as a layer in your AWS account.
make deploy DEPLOYMENT_BUCKET=
By default, this uses imagemagick-layer as the stack name. Provide a
STACK_NAMEvariable when calling
make deployto use an alternative name.
An example project is in the example directory. It sets up two buckets, and listens to file uploads on the first bucket to convert and generate thumbnails, saving to the second bucket. You can deploy it from the root Makefile using:
make deploy-example DEPLOYMENT_BUCKET=
For more information, check out:
Gojko Adzic https://gojko.net