Page 1 of 1

use convert in script to create piclture abels with a space

Posted: 2011-09-06T06:47:48-07:00
by qsecofer
I using convert in a shell (bash) script to create picture labels
the command I use in the script is

convert -background white -fill black -font DejaVu-Sans-Book -size 415x47 label:$NAME ./Images/NAME.jpg

If $NAME contains "Boer" then the line works correct.
If $NAME contains " Christabell Sunday" i get the following error messages

convert: unable to open image `Sunday': @ error/blob.c/OpenBlob/2498.
convert: no decode delegate for this image format `Sunday' @ error/constitute.c/ReadImage/532.

So I guess the question is how do I in a script generate a label texst from a variable with space's in it.

Re: use convert in script to create piclture abels with a sp

Posted: 2011-09-06T07:01:42-07:00
by magick
Add quotes around the label: command line argument.

Re: use convert in script to create piclture abels with a sp

Posted: 2011-09-06T07:10:09-07:00
by qsecofer
Magick thanks for you quick responce.

I have tried

convert -background white -fill black -font DejaVu-Sans-Book -size 415x47 label:"$NAME" ./Images/NAME.jpg
and

convert -background white -fill black -font DejaVu-Sans-Book -size 415x47 label:'$NAME' ./Images/NAME.jpg

but both give me the same error message.

Re: use convert in script to create piclture abels with a sp

Posted: 2011-09-06T10:38:00-07:00
by fmw42
what version of IM are you using and what platform? have you tried the command in command line mode outside your script? the double quotes should work fine. Single quotes won't resolve the variable. did you put quotes in your variable definition? NAME="Christabell Sunday"

This works perfectly fine for me on IM 6.7.2.2 Q16 Mac OSX Tiger.


NAME="Christabell Sunday"
convert -background white -fill black -font Arial -size 415x47 label:"$NAME" tmp1.png

Though the text is left justified. So you might want to add -gravity center. Or just specify only a width or only a height and let label: make the image just fill the text.

Re: use convert in script to create piclture abels with a sp

Posted: 2011-09-06T22:33:54-07:00
by qsecofer
shame on me.

I had the $NAME at two places in the script and only changed 1 to have the quotes.

Problem solved thx