具有透明背景的Imagemagick文本

Imagemagick text with transparent background

我想创建一个带有图像魔法的 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。 基本上应该有一个透明背景的白色文本。

我认为你需要 xc:none 而不是 xc:black,像这样:

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

(我添加了红色边框只是为了让您可以看到它的范围。)

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

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

您还可以添加:

  • -重力中心如果你想让你的文字居中

  • -fill rgba(100%%,0,0,0.80) 如果你想让你的文字是半透明的

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