运行 ImageMagick 作为 AWS lambda 上的 python 子进程
Run ImageMagick as a python subprocess on AWS lambda
我希望通过向 AWS lambda 提供我的 s3 存储桶中的一系列图像来生成动画 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 produced errors ...".
后生成一个空白的 .gif 文件和 returns 一个空的异常线程
只有在 Node.js 中编写了 lambda 函数,才会预装 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.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.
我希望通过向 AWS lambda 提供我的 s3 存储桶中的一系列图像来生成动画 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 produced errors ...".
后生成一个空白的 .gif 文件和 returns 一个空的异常线程只有在 Node.js 中编写了 lambda 函数,才会预装 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.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.