Try caption:
What you want and what you can have are not always the same thing; sometimes you need to compromise.
I do not think fmw42's examples are using C and you may have more problems if the C API when you decide to use it does not support what you want to do. In that case you may need to decide on a different programming method
You can create a separate image with the text in and add it to the bottom of the image which means you can control everything but it will be another step.
Putting text in a rectangle or an overalyed image
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Putting text in a rectangle or an overalyed image
Set the background color with an alpha value, such as rgba(255,255,0,0.5) as half transparent yellow or use hex notation. See http://www.imagemagick.org/script/color.phphim21sri wrote: ↑2017-04-18T03:55:17-07:00 By my understanding annotate will just put text on an image of a defined size but I want the background with some transparency as well, if I set background it will set for the whole image which I don't want. I just want to have a small rectangle at the bottom of image with some color and transparency with some center aligned text.
If you do not want the text to stretch, then specify -size WxH and pointsize in the label: command
For example, for half transparent yellow:
Code: Select all
wid=`convert logo2.gif -format "%w" info:`
convert logo2.gif A_image2.gif -gravity northeast -compose over -composite \
\( -size ${wid}x50 -background "rgba(255,255,0,0.5)" -font arial -pointsize 18 \
-fill black -gravity center label:"This Is Some Text" \) \
-append result.png
For fully transparent background use color "none" or "transparent"
Code: Select all
wid=`convert logo2.gif -format "%w" info:`
convert logo2.gif A_image2.gif -gravity northeast -compose over -composite \
\( -size ${wid}x50 -background none -font arial -pointsize 18 \
-fill black -gravity center label:"This Is Some Text" \) \
-append result.png
Code: Select all
wid=`convert logo2.gif -format "%w" info:`
convert logo2.gif A_image2.gif -gravity northeast -compose over -composite \
\( -size ${wid}x50 xc:yellow -channel a -evaluate set 50% +channel -font arial -pointsize 18 \
-fill black -gravity center -annotate +0+0 "This Is Some Text" \) \
-append result.png
Re: Putting text in a rectangle or an overalyed image
Thanks guys, I am able to achieve what I wanted from command line. I want to implement this in C I have figured everything out regarding how to implement this except I am not able to use compose method in C when I want to overlay a image on an background image, I am using https://www.imagemagick.org/api/magick- ... ositeImage method but when I compile the code I get "undefined symbol : MagickCompositeImage". Please suggest what method should I use to overlay an image over an image.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Putting text in a rectangle or an overalyed image
I asked you:
MagickCompositeImage() works fine for me, in v6. Perhaps you are missing a "#include".
You refer to Wand documentation, so that answers that. But you haven't said which version of IM.snibgo wrote:What version of IM? Which C API, MagickCore or MagickWand?
MagickCompositeImage() works fine for me, in v6. Perhaps you are missing a "#include".
snibgo's IM pages: im.snibgo.com