PIL - transparent ImageDraw.text()

tac-tics tactics40 at gmail.com
Wed Jul 19 12:22:06 EDT 2006


aljosa wrote:
> 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 8-)
>
> 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
=-)




More information about the Python-list mailing list