3
votes

I want to create an iamge with image magick that creates me a text with a transparent background.

So far I used this code but it creates me a black background.

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

The file shall be a .png. There should basically be a a white text with a transparent background.

2

2 Answers

4
votes

I think you need xc:none rather than xc:black, like this:

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

enter image description here

(I added a red border just so you can see the extent of it.)

2
votes

I know it's a late answer, but you should use something like this:

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

You can also add:

  • -gravity Center if you want your text to be centered

  • -fill rgba(100%%,0,0,0.80) if you want your text to be semitransparent

More on creating different canvases here.