I am trying to execute a "*.py" script (in a console from CMD by "python *.py"), which contains the following code ("convert" is a command of ImageMagick):
from subprocess import Popen
fp1 = 'convert'+' '+'Pictures\1110.6437v3.pdf[7]'+' '+'-thumbnail'+' '+'x156'+' '+'thumb.png'
print("fp1=", fp1)
pp = Popen(fp1)
I obtain the following output and error in the console window:
fp1= convert Pictures\1110.6437v3.pdf[7] -thumbnail x156 thumb.png
Invalid parameter - -thumbnail
It is strange because if I input the following command in CMD:
convert 1110.6437v3.pdf[7] -thumbnail x156 thumb.png
it would be OK.
I am not an expert on subprocess or Python. I have just dabbled a little with it. I think your fp1 syntax may be in error. Should it not be square brackets with commas (at least in Python 3.6). See https://docs.python.org/3/library/subprocess.html
But the following works for me to run an ImageMagick command to create an image of the letter "P" in Python 3.6 on Mac OSX.
import subprocess
cmd = '/usr/local/bin/convert -size 30x40 xc:white -fill white -fill black -font Arial -pointsize 40 -gravity South -draw "text 0,0 \'P\'" /Users/fred/desktop/draw_text2.gif'
subprocess.call(cmd, shell=True)
Using shell=True allows one not to have to parse each part of the command. For example with shell=False, I would have to do
import subprocess
cmd = ['/usr/local/bin/convert','-size','30x40','xc:white','-fill','white','-fill','black','-font','Arial','-pointsize','40','-gravity','South','-draw',"text 0,0 'P'",'/Users/fred/desktop/draw_text1.gif']
subprocess.call(cmd, shell=False)