[Image-SIG] how to draw a stroke/outline around text with PIL?

Alec Bennett wrybread at gmail.com
Thu May 14 13:02:32 CEST 2009

I'm trying to draw an outline (what Photoshop calls a stroke) around
some text. Does anyone have any pointers?

Here's the code I'm using to draw the basic text:

import Image, ImageFont, ImageDraw

import win32api

im = Image.open("test.jpg")
pointsize = 30
textcolor = "red"
font = win32api.GetWindowsDirectory() + "\\Fonts\\ARIALBD.TTF"
draw = ImageDraw.Draw(im)
font = ImageFont.truetype(font, pointsize)
draw.text((10, 10), "hi there", font=font, fill=textcolor)

More information about the Image-SIG mailing list