Page 1 of 1

How do I create transparent text

Posted: 2010-05-17T08:42:46-07:00
by kareed
I am trying to create a file with a transparent background and transparent text. I would like to have the text white but have it be a tranparency of 35%. I have tried a lot of things and I can't seem to be able to get it to work. Below is where I am at. I am using label because I don't know what the final dimensions are going to be. Thanks for the help.

convert -background transparent -fill "rgb(255,255,255)" -gravity West -font arial.ttf'
-pointsize 20 label:"This is a test" -background transparent -flatten -trim +repage testFile.png

Re: How do I create transparent text

Posted: 2010-05-17T09:02:12-07:00
by snibgo
As we are trimming, gravity is superfluous. With transparent black background, and opaque White letters, we can multply all alpha values by 0.35 to make the letters semi-transparent:

Code: Select all

convert -background transparent -fill White -font arial.ttf -pointsize 20 label:"This is a test" -channel alpha -evaluate multiply 0.35 -trim +repage testFile.png
An alternative, perhaps more elegant and quicker, is to specify the RGBA of the letters:

Code: Select all

convert -background transparent -fill rgba(255,255,255,0.35) -font arial.ttf -pointsize 20 label:"This is a test" -trim +repage testFile.png
Note that alpha is specified here as a fraction.