Reputation: 409
I'm looking to generate an animated GIF by giving AWS lambda a series of images from my s3 bucket, which it downloads into its /tmp/ folder.
I read in the docs that imagemagick comes preinstalled on lambda, but for some reason I can't call it through a python subprocess:
import subprocess
# ... some code later ...
# Now, generate the gif
input_dir = '/tmp/'
output_dir = '/tmp/'
args = (['convert', '-delay', '60', '-dispose', 'Background', '+page'] +
files_list +
['-loop', '0', os.path.join(output_dir, 'animation.gif')])
try:
subprocess.check_call(args)
print("gif was generated")
except subprocess.CalledProcessError as e:
print("gif produced errors ...")
print(e.output)
any idea how I can go about calling imagemagick through a subprocess on lambda? I've been able to get this working locally and on ec2, but no luck on lambda. The only response I get is it generates a blank .gif file and returns an empty exception thread after outputting "gif produced errors ...".
Upvotes: 3
Views: 2814
Reputation: 52393
Imagemagick is preinstalled only if your lambda function is written in Node.js. But your lambda function written in Python.
From Lambda support
AWS Lambda supports the following runtime versions:
If you author your Lambda function code in Node.js, the following libraries are available in the AWS Lambda execution environment so you don't need to include them:
ImageMagick: Installed with default settings. For versioning information, see imagemagick nodejs wrapper and ImageMagick native binary (search for "ImageMagick"). AWS SDK: AWS SDK for JavaScript version 2.2.12
If you author your Lambda function code in Python, the following libraries are available in the AWS Lambda execution environment so you don't need to include them:
AWS SDK for Python (Boto 3) version 1.2.1
There are no additional libraries available for Java.
Upvotes: 3