我试图从Python脚本像这样ImageMagick的montage
呼叫组装图片:的Python,ImageMagick的和`subprocess`
command = "montage"
args = "-tile {}x{} -geometry +0+0 \"*.png\" out.png".format(width, height)
sys.stdout.write(" {} {}\n".format(command, args))
print subprocess.call([command, args])
然而,蒙太奇只显示用法。如果我手动运行命令,一切正常。 ImageMagick应该支持Windows中的文件名匹配,所以* .png被扩展了。 但显然,这种行为被subprocess
压制。 我是否必须使用glob
才能给montage
提供文件名列表?
更多信息 到目前为止感谢。但是,即使当我使用:
command = "montage"
tile = "-tile {}x{}".format(width, height)
geometry = "-geometry +0+0"
infile = "*.png"
outfile = "out.png"
sys.stdout.write(" {} {} {} {} {}\n".format(command, tile, geometry, infile, outfile))
print [command, tile, geometry, infile, outfile]
#~ print subprocess.call([command, tile, geometry, infile, outfile])
print subprocess.call(['montage', '-tile 9x6', '-geometry +0+0', '*.png', 'out.png'])
我得到一个错误:
Magick: unrecognized option `-tile 9x6' @ error/montage.c/MontageImageCommand/1631.
我在Windows 7中,ImageMagick的6.6.5-7 2010-11-05 Q16 http://www.imagemagick.org,Python 2.7版
问题仍然存在ImageMagick-6.6.7-7-Q16-windows-dll.exe。 – none 2011-02-15 22:16:54
注意错误消息'
'-tile'和'widthxheight'必须是两个不同的列表项。命令行中由空格分隔的所有内容都是一样的。列表项中应该存在的唯一空格是那些如果要直接运行命令就会转义的空间。 – 2011-02-15 22:53:39