python - 将 ImageMagick 与 python 结合使用。 (在 linux 系统上)

标签 python linux imagemagick

<分区>

我想定义一个“调用”imagemagick 来转换图像的函数。

def convert(filein,fileout):
#imagemagick>convert filein fileout

如何通过 Python 调用和使用 imagemagick?

我在 linux 系统上运行,安装了 imagemagick,我没有使用 PIL.module,因为它不处理 PPM[p3]。

最佳答案

免责声明:我是 Wand 的作者。

您可以使用 Wand 轻松做到这一点,ImageMagick for Python 的简单绑定(bind)。例如,以下代码将 PNG 图像转换为 JPEG 图像:

from wand.image import Image

with Image(filename='in.png') as img:
    img.format = 'jpeg'
    img.save(filename='out.jpg')

this tutorial

关于python - 将 ImageMagick 与 python 结合使用。 (在 linux 系统上),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5028216/

相关文章:

linux - 磁盘 I/O 基准测试

linux - "qemu-system-riscv: command not found"

c++ - 如何在 imagemagick 中将 base64 编码图像转换为 PNG?

pdf - 来自 PDFS 的高分辨率图像

imagemagick - 如何将 EXR 转换为 PNG 并同时调整亮度

python - 如何导入模块 PyImgur Python

python - 如何在 python 中对自定义概率密度函数执行 Kolmogorov-Smirnov 拟合优度检验?

python - 如何在多页面应用程序上使用plotly-dash下载文件?

python - numpy.linalg.eigh 与 numpy.linalg.svd 相比如何?

linux - 将 bash 脚本添加到路径