PIL - transparent ImageDraw.text()

A

aljosa

is it possible to create transparent text (~50% transparency) on image?
i'm using the following code to draw text on image:
font = ImageFont.truetype(str(self.font_family)+".ttf", self.font_size)
draw = ImageDraw.Draw(img)
draw.text((10, 10), self.text, font=font,fill=(255,255,255))
<<<

url with example would be nice :cool:

Aljosa Mohorovic
 
T

tac-tics

aljosa said:
is it possible to create transparent text (~50% transparency) on image?
i'm using the following code to draw text on image:

font = ImageFont.truetype(str(self.font_family)+".ttf", self.font_size)
draw = ImageDraw.Draw(img)
draw.text((10, 10), self.text, font=font,fill=(255,255,255))
<<<

url with example would be nice :cool:

Aljosa Mohorovic

Create a new image filled with transparency (either palletted or
alpha). Draw your text to that image instead. Then, paste the
transparent image onto your main image. I don't know of any examples
online, as I learned this through the sweat and pain of trial and error
=-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top