473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

PIL - transparent ImageDraw.text()

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

Jul 19 '06 #1
1 8369
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
=-)

Jul 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Max M | last post by:
I am using PIL to generate som graphs, like: draw = ImageDraw.Draw(im) for graph in self.graphs: polygon = graph.getPolygon() draw.polygon(polygon, outline=graph.color) del draw But the...
8
by: djmanmaster | last post by:
Am I right in thinking that images with transparent areas (GIFs or PNGs) should allow clicks to "pass through" to any underlying elements behind them? I have had no luck getting this to work in...
3
by: toto | last post by:
Hi, Does anybody know how to save an image in GIF format preserving transparent background ?? Here's what I tested : import Image, ImageDraw im = Image.open('/path/to/model.gif') # An...
0
by: alexandre_irrthum | last post by:
Hi there, I am puzzled by the comportment of the line function from the ImageDraw module with regard to the way it draws or does not draw the last pixel of a line. Below I test this function...
1
by: alexandre_irrthum | last post by:
Hi there, Sorry to repost this, but I didn't get any answer one month ago. In essence, it seems that the ImageDraw line function draws lines one pixel shorter in some circumstances. This could...
4
by: ray well | last post by:
in my app i need to make a RichTextbox control transparent. i need it to be a like a pane of glass lying on a sheet of paper, where u can see everything on the sheet of paper not covered by text...
3
by: vul | last post by:
I used to use creating headers (label at the top of the screen) for VB6 forms as 2 labels shifted a little bit with different for colors to get a simulation of a shadow. I set BackColor of both...
3
by: Daniel Mark | last post by:
Hello all: I am looking the sample code posted on PIL website http://www.pythonware.com/library/pil/handbook/imagedraw.htm ################################################ <<Draw a Grey Cross...
4
by: Dale | last post by:
I am creating GIF images with transparent backgrounds on-the-fly for a web app and rendering them by using System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF). I am confident that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.