Calling ImageMagick's convert

Chris Rebert clp at
Mon Dec 22 09:33:56 CET 2008

On Mon, Dec 22, 2008 at 12:15 AM, cmr.Pent at <cmr.Pent at> wrote:
> 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)'convert in.png -resize 640x480 out.png', shell =
> True)
> works, but none of the following does:
> (2)'convert in.png -resize 640x480 out.png')
> (3)['convert', 'in.png', '-resize 640x480',
> 'out.png'])

I think this needs to be:['convert', 'in.png', '-resize', '640x480', 'out.png'])

Otherwise, it gets '-resize 640x480' as a single escaped option when
it's really 2 options, which is the error message you're getting.
You have to split the arguments up just like the shell would, which
basically means at whitespace unless quoting is used, which is not the
case here.


Follow the path of the Iguana...

> (4)['convert', 'in.png', '-resize 640x480',
> 'out.png'], shell = True)
> In these cases, convert program says 'unrecognized option -resize
> 640x480'.
> At the same time,
>['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