Skip to content

Instantly share code, notes, and snippets.

@nomad1072
Forked from bensie/imagemagick.bash
Last active April 8, 2019 15:53
Show Gist options
  • Save nomad1072/d5f11c4e75e094befb2922a389bd4f34 to your computer and use it in GitHub Desktop.
Save nomad1072/d5f11c4e75e094befb2922a389bd4f34 to your computer and use it in GitHub Desktop.
ImageMagick Static Binaries for AWS Lambda
#!/usr/bin/env bash
# Must be run on an Amazon Linux AMI that matches AWS Lambda's runtime which can be found at:
# https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html
#
# As of Jan 10, 2019, this is:
# Amazon Linux AMI 2017.03.1.20170812 x86_64 HVM GP2 (ami-4fffc834)
#
# Lambda includes ImageMagick 6.7.8-9 preinstalled, so you need to prepend PATH
# with the folder containing these binaries in your Lambda function to ensure
# these newer binaries are used.
#
# In a NodeJS runtime, you would add something like the following to the top of
# your Lambda function file:
# process.env['PATH'] = process.env['LAMBDA_TASK_ROOT'] + '/imagemagick/bin:' + process.env['PATH']
#
# This works with both ImageMagick v6.x and v7.x
# version=6.9.10-23
version=7.0.8-35
sudo yum -y install libpng-devel libjpeg-devel libtiff-devel gcc
curl -O https://imagemagick.org/download/ImageMagick-$version.tar.gz
tar xf ImageMagick-$version.tar.gz
cd ImageMagick-$version
./configure --prefix=/var/task/imagemagick --enable-shared=no --enable-static=yes
make
sudo make install
tar zcvf ~/imagemagick.tgz /var/task/imagemagick/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment