我试图在图像上放置一个半透明背景的标题.
这是文档中的示例(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
Run Code Online (Sandbox Code Playgroud)

这是我到目前为止的尝试:
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'
Run Code Online (Sandbox Code Playgroud)
创建的标题按预期放置在合成图像的右上角.唯一的问题是,标题背景是黑色,而不是半透明.我已经看到使用xc命令进行透明度(例如convert -size 50x50 xc:'#879'img.png)但是我没有看到如何应用命令设置标题bg颜色.
编辑:
我刚刚在ec2服务器上测试过,代码按预期工作.代码在Mac 10.7x上运行时会发生此问题.
给它一个 - 它使用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.jpg
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2980 次 |
| 最近记录: |