Page 1 of 1

space before text in label

Posted: 2016-09-02T01:19:06-07:00
by tunezio
Hello

I try to create an image with text and border around the image with a background texture. my problem is that the text is pasted to the edge to the left, and when I try to add a "space" before the text that is ignored but if I add a "space" in the end it works

Code: Select all

convert -resize "240x114>" -extent 240x114 -background black -gravity center -fill white -pointsize 125 -size x114 -font "barata.ttf" label:" My text " -alpha off -trim \( -clone 0 -tile texture_finale.jpg -draw "color 0,0 reset" -fill "#C3F000" -colorize 50% \) \( -clone 0 -fill none -colorize 100% \) -reverse -compose over -composite -alpha set -virtual-pixel transparent -channel A -blur 0x0.7 -level 50,100% +channel \( +clone -background black -shadow 80x3-3+3 \) +swap -background none -layers merge +repage
ImageMagick 6.7.7-10 2016-06-17 Q16

Re: space before text in label

Posted: 2016-09-02T01:55:24-07:00
by snibgo
tunezio wrote:label:" My text "
Adding spaces before and after the text should work. It has worked for me, for years. But your v6.7.7-10 is very very old.

EDIT: Oh, wait, then you "-trim". Well, that trims off the spaces.

Re: space before text in label

Posted: 2016-09-02T02:18:28-07:00
by tunezio
Thank you for your quick answer

This is my last code but is still no working

Code: Select all

convert  -background black -fill white -font "barata.ttf"  -gravity center  -pointsize 125 -size x114 label:" My text "  
 \( -clone 0 -tile texture_finale.jpg -draw "color 0,0 reset" -fill "#C3F000" -colorize 50% \) 
 \( -clone 0 -fill none -colorize 100% \) 
 -reverse -compose over -composite 
 -alpha set -virtual-pixel transparent -channel A -blur 0x0.7 -level 50,100% +channel 
 \( +clone -background black -shadow 80x3-3+3 \) +swap -background none -layers merge +repage
 -resize "400x247 >"
 -extent "400x247"


Re: space before text in label

Posted: 2016-09-02T02:27:32-07:00
by snibgo
It isn't a valid "convert" command. The last thing in a "convert" command must be an output name (usually a filename).

Re: space before text in label

Posted: 2016-09-02T02:30:34-07:00
by tunezio
I just not added it.
My script works, but my problem is haw to add space before text

Code: Select all

convert  -background black -fill white -font "barata.ttf"  -gravity center  -pointsize 125 -size x114 label:" My text "  
 \( -clone 0 -tile texture_finale.jpg -draw "color 0,0 reset" -fill "#C3F000" -colorize 50% \) 
 \( -clone 0 -fill none -colorize 100% \) 
 -reverse -compose over -composite 
 -alpha set -virtual-pixel transparent -channel A -blur 0x0.7 -level 50,100% +channel 
 \( +clone -background black -shadow 80x3-3+3 \) +swap -background none -layers merge +repage
 -resize "400x247 >"
 -extent "400x247"
 088f68a48dd4116b067fda9066b2be54.png
 

Re: space before text in label

Posted: 2016-09-02T02:47:56-07:00
by snibgo
It does seem to have broken, sometime after v6.9.2-5. I suggest you reduce it to the simplest case and report it in the bugs forum.

Re: space before text in label

Posted: 2016-09-02T03:01:46-07:00
by tunezio
You think that an update may fix the problem?

Re: space before text in label

Posted: 2016-09-02T07:55:06-07:00
by GeeMack
tunezio wrote:You think that an update may fix the problem?
You should generally use the most recent version available if you can. But even with IM 7.0.2-10 on Windows 10 a space at the beginning of a label disappears. For this issue you may need to escape the space at the start of your label text. Something like...

Code: Select all

... label:"\ My Text " ...

Re: space before text in label

Posted: 2016-09-02T08:43:37-07:00
by GeeMack
tunezio wrote:I try to create an image with text and border around the image with a background texture. my problem is that the text is pasted to the edge to the left, and when I try to add a "space" before the text that is ignored but if I add a "space" in the end it works
This is an issue even with a current release ImageMagick 7.0.2-10 running on Windows 10 64. When I run this command to test several labels...

Code: Select all

magick -pointsize 48 ^
   label:"My Text 1 2 3" ^
   label:" My Text 1 2 3 " ^
   label:"\ My Text 1 2 3 " ^
   label:"     My Text 1 2 3     " ^
   label:"\     My Text 1 2 3     " ^
   -bordercolor gray -background gray -border 10x10 -append output.png
... you can see how all the spaces at the beginning of the text string in a "label" get removed if the first one isn't escaped with a backslash "\".

Image

This may be a bug that needs to be addressed by the developers, or it may just be if a space is the first character in the "label" it needs to be escaped to make it work.

Re: space before text in label

Posted: 2016-09-02T09:06:29-07:00
by GeeMack
snibgo wrote:It does seem to have broken, sometime after v6.9.2-5. I suggest you reduce it to the simplest case and report it in the bugs forum.
I opened a thread in the "Bugs" section of the forum and provided an example command and output image.