space before text in label

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tunezio
Posts: 26
Joined: 2016-08-09T08:59:20-07:00
Authentication code: 1151

space before text in label

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: space before text in label

Post 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.
snibgo's IM pages: im.snibgo.com
tunezio
Posts: 26
Joined: 2016-08-09T08:59:20-07:00
Authentication code: 1151

Re: space before text in label

Post 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"

snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: space before text in label

Post by snibgo »

It isn't a valid "convert" command. The last thing in a "convert" command must be an output name (usually a filename).
snibgo's IM pages: im.snibgo.com
tunezio
Posts: 26
Joined: 2016-08-09T08:59:20-07:00
Authentication code: 1151

Re: space before text in label

Post 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
 
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: space before text in label

Post 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.
snibgo's IM pages: im.snibgo.com
tunezio
Posts: 26
Joined: 2016-08-09T08:59:20-07:00
Authentication code: 1151

Re: space before text in label

Post by tunezio »

You think that an update may fix the problem?
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: space before text in label

Post 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 " ...
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: space before text in label

Post 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.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: space before text in label

Post 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.
Post Reply