Calling Command Line ImageMagick from Python 3.6 Subprocess Module
Posted: 2017-10-27T15:29:21-07:00
I have just now played around with subprocess module in Python using ImageMagick 6.9.9.20 Q16 Mac OSX Sierra. Both of the following work for me. See http://www.bogotobogo.com/python/python ... module.php
These are the two scripts (on my desktop)
subprocess_convert1.py
subprocess_convert2.py
They are called in a bash shell terminal with:
They both result in

These are the two scripts (on my desktop)
subprocess_convert1.py
Code: Select all
#!/opt/local/bin/python3.6
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)
subprocess_convert2.py
Code: Select all
#!/opt/local/bin/python3.6
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)
Code: Select all
python3.6 subprocess_convert1.py
or
python3.6 subprocess_convert2.py
