6

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.

utdev
  • 3,942
  • 8
  • 40
  • 70

2 Answers2

6

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.)

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
4

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.

thvs86
  • 1,458
  • 2
  • 20
  • 24