Calling ImageMagick's convert

cmr.Pent at gmail.com cmr.Pent at gmail.com
Mon Dec 22 09:15:01 CET 2008


Hello group!

I'm a Python beginner. I'm trying to call ImageMagick's convert
program from my code.
My OS is Debian testing, and my version of Python is 2.5.

I've just stumbled upon a problem:

(1) subprocess.call('convert in.png -resize 640x480 out.png', shell =
True)

works, but none of the following does:

(2) subprocess.call('convert in.png -resize 640x480 out.png')
(3) subprocess.call(['convert', 'in.png', '-resize 640x480',
'out.png'])
(4) subprocess.call(['convert', 'in.png', '-resize 640x480',
'out.png'], shell = True)

In these cases, convert program says 'unrecognized option -resize
640x480'.
At the same time,

subprocess.call(['ls', '-l'])

works as expected.

I'd like to use variant (3), as it seems the most handy. I don't
understand why is shell = True required in case of convert. Is it a
bug in Python, in ImageMagick, or am I missing something very basic
here?
Any hint appreciated.

Andrey



More information about the Python-list mailing list