[magick-users] How to calculate size of the text in pixels to put
text in a limited box (newbie)
Anthony Thyssen
anthony at griffith.edu.au
Sun Mar 11 21:43:29 CDT 2007
"Andrei Stebakov" on wrote...
| Hi,
|
| If let's say I am given a limited box in which I should write some text
| "Hellow, ImageMagick!", how would I calculate font parameters (size etc) to
| make sure the text doesn't exceed the boundaries of the box? Can it be done
| from MagickWand?
|
Don't!!!!!
First use the latest IM release (at least 6.3.2), which has both
auto-sized captions and labels.
If the box is 200x100 pixels use..
convert -size 200x100 caption:'Hellow, ImageMagick!' text_image.gif
This will word wrap the image so the largest font size posible, which
fits the given space. It is about 10 times slower and internally IM
does a lot of trial and error, but it will work.
Just do NOT set a -pointsize, or turn it off with +pointsize.
See IM examples, Text to Image, Captions
http://www.imagemagick.org/Usage/text/#caption
With an image of your test, you can now overlay it into the limited
space.
Anthony Thyssen ( System Programmer ) <A.Thyssen at griffith.edu.au>
-----------------------------------------------------------------------------
"I must not fear. Fear is the mind killer. Fear is the little-death
that brings total obliteration." "Litany Against Fear" - Dune
-----------------------------------------------------------------------------
Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/
More information about the Magick-users
mailing list