【发布时间】:2012-05-31 12:14:47
【问题描述】:
我正在尝试在图像上放置具有半透明背景的标题。
这是来自文档 (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 上运行代码时会出现此问题。
【问题讨论】:
标签: imagemagick