I am trying to rasterize some fonts using imagemagick with this command which works fine from a terminal:
convert -size 30x40 xc:white -fill white -fill black -font "fonts\Helvetica Regular.ttf" -pointsize 40 -gravity South -draw "text 0,0 'O'" draw_text.gif
Running the same command using subprocess to automate it does not work:
try:
cmd= ['convert','-size','30x40','xc:white','-fill','white','-fill','black','-font','fonts\Helvetica Regular.ttf','-pointsize','40','-gravity','South','-draw',"text 0,0 'O'",'draw_text.gif']
#print(cmd)
subprocess.check_output(cmd,shell=True,stderr=subprocess.STDOUT)
except CalledProcessError as e:
print(e)
print(e.output)
.
Command '['convert', '-size', '30x40', 'xc:white-fill', 'white', '-fill', 'black', '-font', 'fonts\\Helvetica Regular.ttf', '-pointsize', '40', '-gravity', 'South', '-draw', "text 0,0 'O'", 'draw_text.gif']' returned non-zero exit status 4
b'Invalid Parameter - 30x40\r\n'
shell = True?shell=True. I tried it withshell=Falsebut that gives me the same error. Anyway, it is not unsafe because I am not using any untrusted input.str.join(' ', cmd)and copy+paste that to the command line to see if it still works.fonts\Helve...andtext 0,0 'O'. I think this is normal because the quotes are only there because of the space in the argument and the shell strips away the quotes before passing them to the program