Page 1 of 1

Semi-Transparent Text on Transparent Background

Posted: 2010-06-15T23:47:47-07:00
by jgrauman
Hello all,

I'm trying to figure out how to create text with a completely transparent background, where the text itself has some transparency as well. I'd like text that is 20% transparent on a completely transparent background. The following achieves what I want (minus the transparent text). Can someone help me figure out how to make the text a certain amount transparent? Thanks!

convert -channel RGBA -gravity center -size 35x17 xc:none -font Arial-Regular -pointsize 13 -fill black -annotate +0+0 Text -background transparent -flatten out.png

Josh

Re: Semi-Transparent Text on Transparent Background

Posted: 2010-06-16T03:26:41-07:00
by snibgo
Red text with 80% opacity (Windows script):

Code: Select all

convert ^
  -size 35x17 xc:none ^
  -gravity Center ^
  -fill rgba(255,0,0,0.80) -font c:\windows\fonts\arial.ttf -pointsize 13 -annotate +0+0 "Text" ^
  out.png

Re: Semi-Transparent Text on Transparent Background

Posted: 2010-06-16T08:57:15-07:00
by jgrauman
Thanks! Works like a charm.

Re: Semi-Transparent Text on Transparent Background

Posted: 2010-06-16T10:01:46-07:00
by snibgo
Tut tut, what was I thinking of? That script should be:

Code: Select all

convert ^
  -size 35x17 xc:none ^
  -gravity Center ^
  -fill rgba(100%%,0,0,0.80) -font c:\windows\fonts\arial.ttf -pointsize 13 -annotate +0+0 "Text" ^
  out.png
which uses the more portable 100%. (Don't double the % for Unix.) Note that alpha in rgba() ranges from 0 to 1. IM will silently ignore a %-sign in the alpha.

Re: Semi-Transparent Text on Transparent Background

Posted: 2010-06-16T19:05:10-07:00
by anthony
Another alternative is just annotate 'red' text on your transparent background.

Then use -channel A -evaluate multiply 0.8 +channel to make everything at least slightly transparent.

This will work with anything text, images etc. And using a color name like 'red' make things a lot easier to edit later.

See IM examples, Transform Images Evaluate Multiply
http://www.imagemagick.org/Usage/transf ... e_multiply