Identify Temp Text

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?".
KandisZZ
Posts: 21
Joined: 2011-02-13T05:47:57-07:00
Authentication code: 8675308

Identify Temp Text

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Identify Temp Text

Post by fmw42 »

try

convert \( -background none -pointsize 12 -font Fonts/font.ttf -size 100x -fill '#12345' -gravity North caption:'text' \) -verbose info:
KandisZZ
Posts: 21
Joined: 2011-02-13T05:47:57-07:00
Authentication code: 8675308

Re: Identify Temp Text

Post 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
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Identify Temp Text

Post 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
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
KandisZZ
Posts: 21
Joined: 2011-02-13T05:47:57-07:00
Authentication code: 8675308

Re: Identify Temp Text

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Identify Temp Text

Post 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
KandisZZ
Posts: 21
Joined: 2011-02-13T05:47:57-07:00
Authentication code: 8675308

Re: Identify Temp Text

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Identify Temp Text

Post 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
KandisZZ
Posts: 21
Joined: 2011-02-13T05:47:57-07:00
Authentication code: 8675308

Re: Identify Temp Text

Post by KandisZZ »

OMG sry 6.5.7-8 is the right Version...

Marc.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Identify Temp Text

Post 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.
KandisZZ
Posts: 21
Joined: 2011-02-13T05:47:57-07:00
Authentication code: 8675308

Re: Identify Temp Text

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Identify Temp Text

Post 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:
KandisZZ
Posts: 21
Joined: 2011-02-13T05:47:57-07:00
Authentication code: 8675308

Re: Identify Temp Text

Post 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.
KandisZZ
Posts: 21
Joined: 2011-02-13T05:47:57-07:00
Authentication code: 8675308

Re: Identify Temp Text

Post 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:
Last edited by KandisZZ on 2011-12-05T15:52:35-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Identify Temp Text

Post 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:
Last edited by fmw42 on 2011-12-05T15:57:14-07:00, edited 4 times in total.
Post Reply