更新: os.system提供了錯誤信息,這看起來很奇怪。爲什麼在圖像路徑之前沒有C:?絕對有文件夾中的文件。用python腳本中的imagemagick將tif文件轉換爲gif特定的命令
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文件用下面python腳本吩咐GIF。但是,似乎是當我將圖像列表傳遞給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它給出了錯誤信息: – 2015-03-02 16:00:47