Page 1 of 1
Questions about annotations
Posted: 2009-04-30T13:35:01-07:00
by Wimweb
Hello,
I've got 2 questions about annotations :
1) How can I give an annotation a image background?
2) How can I get place where my last annotation ended? (I need to need to put text with images through eachother on an image)
Thanks
Re: Questions about annotations
Posted: 2009-04-30T14:33:08-07:00
by fmw42
For question 1) see -background using label or caption at
http://www.imagemagick.org/Usage/text/
also see -undercolor for -draw or -annotate
For question 2) I don't think you can, once the image has been created, but you could use -debug annotate with -annotate to get Font Metrics. See same page above.
Re: Questions about annotations
Posted: 2009-04-30T18:42:35-07:00
by anthony
annotate draws on top of an existing image, backgroudn is that image.
label: and caption; creates and image and background can be set using -background before the image creation operator.
See
http://www.imagemagick.org/Usage/text/
Re: Questions about annotations
Posted: 2009-05-01T07:14:33-07:00
by Wimweb
Background is only for colors, I need an image.
EDIT : I got an idea. Can I solve this by making a seperate image with the textback and the text, and then put it on the main image? I'll try it this way.
Still, any suggestions for question 2?
Re: Questions about annotations
Posted: 2009-05-01T08:53:34-07:00
by Bonzo
Just write the text on the image:
Code: Select all
convert image.jpg -fill black -pointsize 20 -font verdana -gravity center -annotate +0+0 "Some text" output.jpg
As Fred says question 2 is not easy. If you are still using php you may be able to calculate it:
Draw the text onto an image - find the size of the text image with getimagesize() - get size of image you are going to put the text onto again with getimagesize()- take the width of the text image away from the position of the text image on the background image.
Re: Questions about annotations
Posted: 2009-05-01T19:30:09-07:00
by anthony
For question 2 you need to find out how big the test is and how far the 'caret' moves.
This can be difficult without using an API.
See IM Examples, Determining Font Metrics
http://www.imagemagick.org/Usage/text/#font_info
Note label can get something like that info, but it is not exact, See the next section...
IM Examples, Creating Lines of Mixed Font Styles
http://www.imagemagick.org/Usage/text/#mixed_font_lines
You can generate a label or test on a transparent background
-background none, and then overlay that text onto the image. This is actually very common as it give you far more control, and allows you to do other things to the text before it is overlaid onto the image.
Finally if you plan to do a LOT of this then IM may not be the right tool. The TeX and the higher level tools LaTeX and its GUI tool LyX, is designed to actually do text and font layouts, spacing, justifications, word wrapping, and pagation of characters, words, sentantaces paragraphs, etc etc etc. If you are serious about text handling in batch processing, than these are the tools to use.
Re: Questions about annotations
Posted: 2009-05-01T23:59:03-07:00
by Wimweb
Wat you say there about seperate images with a -background none, is a very good idea. I can then get there width via php, and determine the x and y for the next image.
Problems solved. Thanks everyone!