[Zope] Re: PIL Problem
Max M
maxmcorp@worldonline.dk
Wed, 13 Dec 2000 18:14:30 +0100
--- Luc Tonin <ltonin@lw.mth.tv> wrote:
> well
> i m still trying to insert some text in a gif image
> using PIL
> but what should i do??? using da PSDraw class??
> does anybody have an id ??
> thx by advance
Here is an example I got working under Windows.
PIL has very limited font/text support though.
I got this working pretty fast, as PIL is very well written, but I cannot
find a way to transfer my Windows truetype fonts to PIL's proprietary
format.
Bummer.
regard Max M
---------------------------------------
buttonList = {}
buttonList['02_home.gif'] = 'Ölwechselung'
buttonList['02_01_somewhere.gif'] = 'Klares Bekenntnis zur Umwelt'
buttonList['02_02_dude.gif'] = 'Hey Dude'
import ImageDraw, ImageFont
import Image
# Set font
arial =
ImageFont.load('C:/root/pythonScripts/PILTest/phontz/Verdana_12_100.pil')
im = Image.open("C:/root/pythonScripts/PILTest/redButton.gif")
width, height = im.size
middle = width/2
for fileName, theText in buttonList.items():
aCopy = im.copy()
# render the text
draw = ImageDraw.Draw(aCopy)
draw.setfont(arial)
draw.setink(255)
textWidth, textHeight = draw.textsize(theText)
textMiddle = textWidth/2
fontPlacement = middle - textMiddle
print textWidth
draw.text((fontPlacement, -3), theText)
aCopy.save('C:/root/pythonScripts/PILTest/' + fileName)
---------------------------------------
Max M. W. Rasmussen, Denmark. New Media Director
private: maxmcorp@worldonline.dk work: maxm@normik.dk
-----------------------------------------------------
Specialization is for insects. - Robert A. Heinlein