Page 1 of 2

Identify Temp Text

Posted: 2011-12-05T12:41:36-07:00
by KandisZZ
Hello Forum.
Need Some help with this
I want to get the format of generated Text:

Code: Select all

identify -background  none -pointsize 12 -font Fonts/font.ttf -size 100x -fill '#12345'  -gravity North caption:'text' PNG:-
There is no Output.
Image passthru (with convert) works fine.
But no Information about the temp image.

thx for help!

Marc

Re: Identify Temp Text

Posted: 2011-12-05T13:30:36-07:00
by fmw42
try

convert \( -background none -pointsize 12 -font Fonts/font.ttf -size 100x -fill '#12345' -gravity North caption:'text' \) -verbose info:

Re: Identify Temp Text

Posted: 2011-12-05T14:15:15-07:00
by KandisZZ
thx for this!
I get a result out.

But the geometry value, especially the height of the Png is wrong.
Whats wrong with this?

Marc

Re: Identify Temp Text

Posted: 2011-12-05T14:31:40-07:00
by el_supremo
When I try Fred's command it fails with:

Code: Select all

Magick: unable to open image `#12345': No such file or directory @ error/blob.c/OpenBlob/2589.
Magick: no decode delegate for this image format `#12345' @ error/constitute.c/ReadImage/532.
The fill value should have an even number of digits. #123456 works and produces a 100x15 image.

What height are you expecting?

Pete

Re: Identify Temp Text

Posted: 2011-12-05T14:37:09-07:00
by KandisZZ
Hi.
Yes hex is ok. Its just a demo cmd string.

The Text is generated.
For example a 54 px high Text shows up: 100x90 +0+0
I checked in PS. Its always wrong.

My Goal is to check if the Text is too large for an given Textbox.

thx.
marc.

Re: Identify Temp Text

Posted: 2011-12-05T14:43:05-07:00
by fmw42
using caption, the text will never be too long as you specified a given width and let IM make the height as big as needed. The only issue might be if your width is too small to fit a single word given your pointsize specification.

I had not noticed the number of digits in the hex value, but I think you need to specify it according the IM specs at http://www.imagemagick.org/script/color.php

I had not noticed, but I do get an error message after the verbose info: about


convert: unable to open image `#12345': No such file or directory @ error/blob.c/OpenBlob/2589.
convert: no decode delegate for this image format `#12345' @ error/constitute.c/ReadImage/532.


Which is probably complaining about the the number of digits.

Doing it properly with one more digit gives no error message:

convert \( -background none -pointsize 12 -font Fonts/font.ttf -size 100x -fill '#123456' -gravity North caption:'text' \) -verbose info:

And the verbose information shows:

Geometry: 100x14+0+0

This matches the actual size generated from:

convert \( -background none -pointsize 12 -font Fonts/font.ttf -size 100x -fill '#123456' -gravity North caption:'text' \) tmp.png
identify tmp.png
tmp.png PNG 100x14 100x14+0+0 8-bit PseudoClass 2c 240B 0.000u 0:00.000

What version of IM are you using and what platform? Perhaps your IM needs upgrading?

Note that caption has recently been changed to support Pango. But there are bug reports when using Pango. See viewtopic.php?f=3&t=19868

Re: Identify Temp Text

Posted: 2011-12-05T14:54:15-07:00
by KandisZZ
Hex is no problem.
The behavior of the caption is ok.

I just want to check if the text is too large for the given Textbox.
So i generate the Text -> Output as PNG.
next check Text height, if too large -> notice.

I found this thread with the same problem of PNG height:
viewtopic.php?t=16075&p=58583

I have IM 5.6 (cant upgrade)
So is there a calculating workaround?

thx.

Re: Identify Temp Text

Posted: 2011-12-05T14:57:47-07:00
by fmw42
KandisZZ wrote:Hex is no problem.
The behavior of the caption is ok.

I just want to check if the text is too large for the given Textbox.
So i generate the Text -> Output as PNG.
next check Text height, if too large -> notice.

I found this thread with the same problem of PNG height:
viewtopic.php?t=16075&p=58583

I have IM 5.6 (cant upgrade)
So is there a calculating workaround?

thx.

IM 5.6 is very ancient. I don't know if there is any workaround if you are not getting the right size. But I am not an expert on such an old IM version.


What size do you get from creating:

convert \( -background none -pointsize 12 -font Fonts/font.ttf -size 100x -fill '#123456' -gravity North caption:'text' \) tmp.png

And then using

identify tmp.png

or

identify -verbose tmp.png

or

convert tmp.png -verbose info:


The only alternative I can suggest is to trim the image to the minimum bounding box around the text itself.

convert \( -background none -pointsize 12 -font Fonts/font.ttf -size 100x -fill '#123456' -gravity North caption:'text' \) -trim +repage tmp.png

Re: Identify Temp Text

Posted: 2011-12-05T15:03:50-07:00
by KandisZZ
OMG sry 6.5.7-8 is the right Version...

Marc.

Re: Identify Temp Text

Posted: 2011-12-05T15:15:05-07:00
by fmw42
KandisZZ wrote:OMG sry 6.5.7-8 is the right Version...

Marc.

Is the image correct, but the reported size wrong? If the image is too tall, then try the -trim +repage to get the minimum bounding box about the text itself.

Re: Identify Temp Text

Posted: 2011-12-05T15:22:56-07:00
by KandisZZ
I just checked a longer text.

convert \( -background none -pointsize 12 -font Fonts/font.ttf -size 100x -fill '#123456' -gravity North caption:'text' \) -verbose info:
Wrong Height: 90

If i render it first:
convert -background none -pointsize 80 -font Fonts/font.ttf -size 100x -fill '#123456' -gravity North caption:'text' \) tmp.png

and then check:
identify -verbose tmp.png
Right height is displayed: 54

Re: Identify Temp Text

Posted: 2011-12-05T15:30:49-07:00
by fmw42
try

convert \( -background none -pointsize 12 -font Fonts/font.ttf -size 100x -fill '#123456' -gravity North caption:'text' \) -format "%wx%h" info:

or

convert \( -background none -pointsize 12 -font Fonts/font.ttf -size 100x -fill '#123456' -gravity North caption:'text' \) miff:- | convert - -format "%wx%h" info:

or

convert \( -background none -pointsize 12 -font Fonts/font.ttf -size 100x -fill '#123456' -gravity North caption:'text' \) png:- | convert - -format "%wx%h" info:

Re: Identify Temp Text

Posted: 2011-12-05T15:38:07-07:00
by KandisZZ
The result of your command is 13.

But other text with more digits is wrong. Also Tried different fonts. But this shouldnt matter.
If i check a rendered temp image -> right.
if i check on the fly-> wrong.

Re: Identify Temp Text

Posted: 2011-12-05T15:47:47-07:00
by KandisZZ
So this Code. In your three variants gives me the height of 96.
True Height: 48

Code: Select all

convert \( -background  none -pointsize 14  -size 181x -fill '#123456' -gravity North caption:'Du, Herr, umgibst mich mit deinem Schutz, du hörst mich in deinem Heiligtum.' \) png:- | convert - -format '%wx%h' info:

Re: Identify Temp Text

Posted: 2011-12-05T15:52:27-07:00
by fmw42
Part of the issue is that you have not specified a font and so get your system default font. So that might explain why I get different results from you.

I get 181x60 for the size.


Again, I would try adding -trim +repage and see what you get.


convert \( -background none -pointsize 14 -size 181x -fill '#123456' -gravity North caption:'Du, Herr, umgibst mich mit deinem Schutz, du hörst mich in deinem Heiligtum.' \) -trim +repage png:- | convert - -format '%wx%h' info: