【发布时间】:2015-05-03 00:38:38
【问题描述】:
更新: os.system 给出了错误信息,看起来很奇怪。为什么图片路径前没有 C:?文件夹里肯定有文件。
convert.exe: unable to open image `\\Users\\admin\\Desktop\\test\\1.tif',': No
such file or directory @ error/blob.c/OpenBlob/2643.
convert.exe: no decode delegate for this image format `\\Users\\admin\\Desktop\\
test\\1.tif',' @ error/constitute.c/ReadImage/555.
convert.exe: unable to open image `\\Users\\admin\\Desktop\\test\\2.tif',': No
such file or directory @ error/blob.c/OpenBlob/2643.
convert.exe: no decode delegate for this image format `\\Users\\admin\\Desktop\\
test\\2.tif',' @ error/constitute.c/ReadImage/555.
convert.exe: unable to open image `\\Users\\admin\\Desktop\\test\\3.tif']': No
such file or directory @ error/blob.c/OpenBlob/2643.
convert.exe: no decode delegate for this image format `\\Users\\admin\\Desktop\\
test\\3.tif']' @ error/constitute.c/ReadImage/555.
convert.exe: no images defined `C:\Users\admin\Desktop\test\animated.gif' @ error/
convert.c/ConvertImageCommand/3147.
我想使用 imagemagick 将 tif 文件转换为 gif 并使用下面的 python 脚本给定命令。但是,似乎当我将图像列表传递给 imagemagick 命令行字符串convert -alpha deactivate -verbose -delay 50 -loop 0 -density 300 {} {}animated.gif'.format(images, path) 时,imagemagick 无法识别图像列表。
import os
path = "C:\\Users\\admin\\Desktop\\test\\"
filenames = ["2.tif", "1.tif", "3.tif"]
images = [path + filename for filename in filenames]
os.system('convert -alpha deactivate -verbose -delay 50 -loop 0 -density 300 {} {}animated.gif'.format(images, path))
通常,我可以使用命令行convert -alpha deactivate -verbose -delay 50 -loop 0 -density 300 *.tif animated.gif' 来转换当前文件夹的内容。但是像这种方式我不能指定我想要的 tif 文件顺序。它会将文件转换为1.tif、2.tif、3.tif 顺序为最终的 gif。
那么有没有办法将 python 列表传递给 imagemagick 命令行字符串?
【问题讨论】:
-
@unutbu 它给出了错误信息:
标签: python imagemagick