[Image-SIG] write text on a picture

Ricardo Niederberger Cabral nieder@mail.ru
Mon, 7 Apr 2003 21:18:49 -0300


On Mon, 7 Apr 2003 18:49:32 -0400
Fei Xu <feix@rutchem.rutgers.edu> wrote:

> HI! Everyone: I am using pytohn image library to draw a picture with some
> text on it.  I can draw things like circles, etc, which means my python
> library works well. But I can't write text on it. 
> >>>write.text((0, 0, 100,100), 'red') Traceback (most recent call last):

Try something like:

ifo=ImageFont.load("courB12.pil")
draw.text((0,0),caption,(100,100,100),font=ifo)

where:
(0,0) is the text coordinate
(100,100,100) is the text color RGB triple
caption is a string
"courB12.pil" is the filename of an existing pil font file. (you may need to include full path if not in current dir)
(I believe a corresponding courB12.pbm must also exist at the same path)

You can get some pil fonts at http://effbot.org/pil/pilfonts.zip

Best regards,
---
rnc <nieder|at|mail.ru>