ImageMagick의 montage
호출을 사용하여 다음과 같은 Python 스크립트에서 이미지를 어셈블하려고합니다.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에서 파일명 globbing을 지원하기 때문에 * .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
오류 메시지 \'
'타일'및 '너비 x 높이'는 서로 다른 두 개의 목록 항목이어야합니다. 공백으로 구분 된 명령 줄의 모든 내용이 동일하게 적용됩니다. 목록 항목 내에 존재해야하는 유일한 공백은 명령을 직접 실행하면 탈출 할 수있는 공백입니다. –