Determine "bounding box" of -annotate command?

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
webunity

Determine "bounding box" of -annotate command?

Post by webunity »

Is it possible to get the bounding box of the text written using annotate?

For instance, i want to use imagemagick to create headers (or menu images) for my sites. Dynamically, based on CMS input.

Right now i have this:

Code: Select all

convert 'basel1.gif' -fill white -font verdana.ttf -pointsize 10 -gravity north -annotate +0+0 'HOME' Label_IM.jpg
Which basically tells it:
Take baseL1.gif, Write some text using a white font and the Verdana font with pointsize 10.

So far so good, but how do i know the width/height of the written text, is it possible to retreive that information?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Determine "bounding box" of -annotate command?

Post by fmw42 »

Have you tried -debug annotate. See http://www.imagemagick.org/Usage/basics/#controls

also see

viewtopic.php?f=1&t=13427&hilit=debug+annotate

Don't know if that helps or not?

Often I will use label: to make a test image to find out how big it is, then redo it with -annotate.

see
http://www.imagemagick.org/Usage/text/#label
http://www.imagemagick.org/Usage/text/#annotate_size
webunity

Re: Determine "bounding box" of -annotate command?

Post by webunity »

@fmw42: Thanx! I have to use an older version so i got it working by doing this:
http://www.imagemagick.org/Usage/text/#font_info
convert -size 250x250 xc:lightblue -gravity north-west -font verdana.ttf -pointsize 9 -fill none -undercolor white -annotate +0+0 'WebUnity' -trim info:
Post Reply