Search code examples
pythoncmdpostscriptimagemagick-convert

ImageMagick Conversion from .ps to .png, run from python - invalid param


I have been looking through some similar posts and through the ImageMagick page, but I cannot seem to find a reason for my issue:

Note I am using a windows machine.

I have a .ps image in a folder and it works when running with the command to convert it from the cmd: convert saved.ps newsaved.png

However when I try to execute it from my python script with the following code:

args = ["convert","saved.ps newsave.png"] subprocess.Popen(args) #or this call(args) os.system("start newsave.png")

The cmd window says that newsave.png is an invalid parameter. (The error message being: Invalid parameter - newsave.png in the cmd window, which then closes instantly)

Having the everything seperated by a comma in args has also not helped. os.getcwd() returns the current work directory as well, so I know I'm in the right dir. The error happens when the subprocess is called.


Solution

  • In the end I had to add shell=True in order for the conversion to work properly.

    args = ["convert", "saved.ps", "newsave.png"] subprocess.call(args, shell=True)

    Thanks to Warren for the help.