Imagemagick文本有透明背景

时间:2016-10-07 14:02:05

标签: image imagemagick imagick

我想创建一个带有图像magick的iamge,它创建了一个透明背景的文本。

到目前为止,我使用了这段代码,但它创建了一个黑色背景。

convert -debug annotate -size 720x480 -background none xc:black -fill white -stroke white -font Arial -pointsize 16 90x25 -draw "text 120,370 'move'"-font Arial -pointsize 16 50x25 -draw "text 250,370 'text'"-font Arial -pointsize 16 105x25 -draw "text 360,370 'images'"-font Arial -pointsize 16 115x25 -draw "text 500,370 'another text'" TextTransp.png

该文件应为.png。 应该基本上有一个透明背景的白色文本。

2 个答案:

答案 0 :(得分:2)

我知道这是一个迟到的答案,但你应该使用这样的东西:

convert -size 115x25 xc:none -font PATH\TO\YOUR\FONT -pointsize 16 -annotate +0+0 "TEXT" PATH\TO\FINAL\FILE.png

您还可以添加:

  • -gravity Center 如果您希望文本居中

  • -fill rgba(100 %%,0,0,0.80)如果您希望自己的文字是半透明的

有关创建不同画布的更多信息here

答案 1 :(得分:1)

我认为您需要xc:none而不是xc:black,如下所示:

convert -size 720x480 xc:none -draw "text 200,50 'Hello there'" result.png

enter image description here

(我添加了一个红色边框,以便您可以看到它的范围。)

相关问题