我试着在图片上放置一个半透明背景的标题。
以下是文档(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

这是我到目前为止的尝试:
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'正如预期的那样,标题被创建并放置在合成图像的右上角。唯一的问题是,标题背景是黑色的,而不是半透明的。我已经看到了使用xc命令来实现透明度(例如,convert -size 50x50 xc:'#879‘img.png),但我不知道如何应用该命令来设置标题bg颜色。
编辑:
我刚刚在ec2服务器上进行了测试,代码按预期工作。当代码在Mac 10.7x上运行时,会出现此问题。
发布于 2012-05-31 23:55:37
尝试一下,它正在使用带透明度的rgb ( 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.jpghttps://stackoverflow.com/questions/10833394
复制相似问题