IM7 on AWS Lambda
Posted: 2016-06-10T12:20:34-07:00
'AWS Lambda' is Amazon's microservice platform. You create a function in either Node.js or Python, connect it to an endpoint, this endpoint takes the payload of a request as input, processes this through the function, and returns a response (as well as executing any peripheral actions such as write to a database). You can read more about it here: https://aws.amazon.com/lambda/.
AWS Lambda comes with ImageMagick 6 pre-installed on their instances, which are running their own proprietary 'Amazon Linux' (appears to be a derivative of CentOS). Since there is no way to control the system or environment that the instances are launched with, one must include all function dependencies within their function code, including application binaries, as well as set any necessary environment variables to prepend search paths.
I have been using ImageMagick 6 just fine for the past few months, but have hit a situation where HDRI makes a significant difference in image quality. Thus, I have begun my quest in getting ImageMagick 7 to run on AWS Lambda.
What I've tried so far:
1. Boot up and access an EC2 Amazon Linux instance
2. Install the image delegates I need
3. Build ImageMagick 7 from source
4. Extract the 'magick' binary from /usr/local/bin (along with the appropriate symlinks)
5. Extract the /usr/local/lib libraries
6. Bundle the bin/ and lib/ directories into my AWS Lambda function code
7. Within my code, prepend the bin/ directory to $PATH, and prepend the lib/ directory to $LD_LIBRARY_PATH
(8. In case this is important, I also removed the static libraries to reduce total size)
With this setup, I made a simple test to check the output of 'convert -version', and this is the output:
So far so good. However, when I try to actually do anything with it, this is the output I get:
But, in my lib/ directory, it is there at
Is the directory for configure.xml somehow hard-coded (not using $LD_LIBRARY_PATH)? If so, how can I fix that?
AWS Lambda comes with ImageMagick 6 pre-installed on their instances, which are running their own proprietary 'Amazon Linux' (appears to be a derivative of CentOS). Since there is no way to control the system or environment that the instances are launched with, one must include all function dependencies within their function code, including application binaries, as well as set any necessary environment variables to prepend search paths.
I have been using ImageMagick 6 just fine for the past few months, but have hit a situation where HDRI makes a significant difference in image quality. Thus, I have begun my quest in getting ImageMagick 7 to run on AWS Lambda.
What I've tried so far:
1. Boot up and access an EC2 Amazon Linux instance
2. Install the image delegates I need
3. Build ImageMagick 7 from source
4. Extract the 'magick' binary from /usr/local/bin (along with the appropriate symlinks)
5. Extract the /usr/local/lib libraries
6. Bundle the bin/ and lib/ directories into my AWS Lambda function code
7. Within my code, prepend the bin/ directory to $PATH, and prepend the lib/ directory to $LD_LIBRARY_PATH
(8. In case this is important, I also removed the static libraries to reduce total size)
With this setup, I made a simple test to check the output of 'convert -version', and this is the output:
Code: Select all
Version: ImageMagick 7.0.1-10 Q16 x86_64 2016-06-10 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): freetype jng jpeg png tiff zlib
Code: Select all
convert: UnableToOpenConfigureFile `configure.xml' @ warning/configure.c/GetConfigureOptions/709.
Code: Select all
lib/ImageMagick-7.0.1/config-Q16HDRI/configure.xml