Page 1 of 1

Calling convert from Python script

Posted: 2017-08-14T05:53:53-07:00
by mfkfx
Hello,

I think I have a problem with escape sequences when calling "convert" from Python using os.system('convert...').
I want to draw a text in an Image like this:
"Temperature: 28.1 °C"

What is working:

Code: Select all

-draw \"text 40,240 Humidity_'+format(round(humidity,1))+'\"
which results in "Humidity_39.6"

What is not working:

Code: Select all

-draw \"text 40,240 Humidity:'+format(round(humidity,1))+'\"
which results simply in "Humidity" with error message "convert: non-conforming drawing primitive definition `:' @ error/draw.c/DrawImage/3184."

Same thing here:

Code: Select all

-draw \"text 40,240 Humidity\ '+format(round(humidity,1))+'\"
which results in "Humidity\ 39.6". So the space is displayed correctly, but the line continuation character is drawn as well


Can you help me? It would be great to have a tab between the fixed text and the value. For example:

Code: Select all

Temperature:	17.3 °C
Humidity:	48.2 %rH
Thank you very much in advance!

Regards

Re: Calling convert from Python script

Posted: 2017-08-14T06:11:18-07:00
by snibgo
When a string contains a space, it must be quoted, or the parser won't know where it ends. The same is true of the colon character, and probably others.