Skip to content

Instantly share code, notes, and snippets.

@ezioruan
Forked from bensie/imagemagick.bash
Created October 17, 2017 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezioruan/7cf13077a42af414fb217c7c81b5fbeb to your computer and use it in GitHub Desktop.
Save ezioruan/7cf13077a42af414fb217c7c81b5fbeb 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
# As of Nov 23, 2015, this is Amazon Linux AMI 2014.09.2 x86_64 (ami-0c682c64)
#
# 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.
sudo yum -y install libpng-devel libjpeg-devel libtiff-devel gcc
curl -O http://www.imagemagick.org/download/ImageMagick.tar.gz
tar zxvf ImageMagick.tar.gz
cd ImageMagick
./configure --prefix=/var/task/imagemagick --enable-shared=no --enable-static=yes
make
sudo make install
tar zcvf ~/imagemagick.tgz /var/task/imagemagick/
@ezioruan
Copy link
Author

   var IM_PATH = process.env['LAMBDA_TASK_ROOT'] + "/imagemagick/bin/";
   process.env['LD_LIBRARY_PATH'] = '/var/task/imagemagick/lib/';
   process.env['PATH'] = process.env['PATH'] + ':' + IM_PATH;
   var gm = require('gm').subClass({
     imageMagick: true,
    appPath: '/var/task/imagemagick/bin/',
  });

remember to put the imagemagick floder in the root folder

@ezioruan
Copy link
Author

ezioruan commented Jan 24, 2018

with freetype
you need to

yum install gcc gcc-c++ freetype-devel glib2-devel cairo-devel
./configure --prefix=/var/task/imagemagick -with-freetype=yes  --enable-shared=no --enable-static=yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment