I'm trying to center some graphical text using the PIL. Anyone have a clue
how to do this?

If there's some way of knowing how big the resulting graphical word is, I
could obviously center it.

For example:

import ImageFont, ImageDraw, Image

image_file = "button.jpg"
image = Image.open(image_file)
font = "arial.ttf"

draw = ImageDraw.Draw(image)
font = ImageFont.truetype(font, 12)
draw.text((1, 1), "hi there", font=font)

image.save("temp.jpg")


In the above code, the 1, 1 is the x & y coordinates for the text.
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to