【问题标题】:imagemagick caption with semi-transparent background带有半透明背景的 imagemagick 标题
【发布时间】: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


    【解决方案1】:

    试一试 - 它使用具有透明度的 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
    

    【讨论】:

    • 没有错误但也没有透明度 - 纯绿松石背景
    • 我只能说它对我有用。尝试在数字和 ( ) 之间留一个空格,如 rgba( 0,255,255,0.25 ) 或将颜色括在 ' like 'rgba(0,255,255,0.25)' 中
    • 奇怪,我刚刚在 ec2 服务器上尝试过,它按预期工作。当函数在 mac 10.7 上运行时,似乎会出现问题。
    猜你喜欢
    • 2011-09-15
    • 2011-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-24
    • 2015-11-12
    • 2011-09-15
    相关资源
    最近更新 更多