在AWS Lambda上将ImageMagick作为python子进程运行
作者:互联网
我希望通过从我的s3存储桶中给AWS lambda提供一系列图像来生成动画GIF,并将其下载到/ tmp /文件夹中.
我在文档中读到imagemagick预先安装在lambda上,但是由于某些原因,我无法通过python子进程调用它:
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)
知道如何通过lambda上的子过程调用imagemagick吗?我已经能够使它在本地和ec2上正常工作,但是lambda却没有运气.我得到的唯一响应是,它生成一个空白的.gif文件,并在输出“ gif产生的错误…”后返回一个空的异常线程.
解决方法:
仅当您的lambda函数是用Node.js编写时才预安装Imagemagick.但是您的lambda函数是用Python编写的.
AWS Lambda supports the following runtime versions:
> Node.js:v0.10.36
> Java:Java 8
> Python:Python 2.7
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.12If 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.
标签:imagemagick-convert,amazon-web-services,amazon-s3,aws-lambda,python 来源: https://codeday.me/bug/20191119/2034846.html