I'm trying to call an ImageMagick command from Python 2.7 using subprocess.call. My problem is that the argument parser in subprocess puts a double quotation mark around every argument, and ImageMagick seems to have a problem with quotes around non-file arguments.
What I'd like is something like this
"imagemagick.exe" "im1.png" "im2.png" -alpha off ( ... ) -composite "im3.png"
So far I couldn't find a way to do it with subprocess, other than manually constructing the string with ugly + " " +
elements and calling it with shell=True
.
Here is my code:
args = [ imagemagick,
filename + "_b.bmp",
filename + "_w.bmp",
"-alpha off ( -clone 0,1 -compose difference -composite -negate ) ( -clone 0,2 +swap -compose divide -composite ) -delete 0,1 +swap -compose Copy_Opacity -composite",
filename + ".png" ]
subprocess.call( args )
Is there any way to call the correct command without double quotes using subprocess?
Update: inserted the full command line. I'd like to keep that part together, not as "alpha", "-off", ... one by one.