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
Semi-Transparent Text on Transparent Background
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Semi-Transparent Text on Transparent Background
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
snibgo's IM pages: im.snibgo.com
Re: Semi-Transparent Text on Transparent Background
Thanks! Works like a charm.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Semi-Transparent Text on Transparent Background
Tut tut, what was I thinking of? That script should be:
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.
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
snibgo's IM pages: im.snibgo.com
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Semi-Transparent Text on Transparent Background
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
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/