Reputation: 3580
I am trying to place a caption with a semi-transparent background on an image.
This is the example from the docs (http://www.imagemagick.org/Usage/annotating):
width=`identify -format %w dragon.gif`; \
convert -background '#0008' -fill white -gravity center -size ${width}x30 \
caption:"Faerie Dragons love hot apple pies\!" \
dragon.gif +swap -gravity south -composite anno_caption.jpg
This my attempt so far:
convert -background transparent -colorspace transparent -fill white -gravity center -size 300x300 \
-font fonts/customfont.ttf caption:'caption text here' \
'cap.png'
composite -geometry +0+0 'cap_1.png' 'img_1.jpg' 'img_2.jpg'
the caption is created an placed in the top right hand coner of the composite image as expected. The only problem is, the caption background is black, not semi-transparent. I have seen the use of the xc command for transparency (e.g. convert -size 50x50 xc:'#879' img.png) but I do not see how to apply the command to set the caption bg colour.
EDIT:
I just tested on an ec2 server and the code works as expected. This issue occurs when the code is run on a Mac 10.7x.
Upvotes: 1
Views: 3423
Reputation: 5299
Give this a go - it is using rgb with transparency ( rgba ).
convert -size 300x300 -background rgba\(0,255,255,0.25\) -fill white -gravity center caption:'caption text here' cap.png
composite -geometry +0+0 cap.png img_1.jpg img_2.jpg
Upvotes: 6