By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,100 Members | 2,892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,100 IT Pros & Developers. It's quick & easy.

Creating text on images

P: n/a
Hi all,

I'm trying to create a script that will superimpose text on an image.
I didn't find any great examples out there on how this can be done (I
presume using PIL is necessary), do you know of any examples?
Thanks,

Morten

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
morphex wrote:
Hi all,

I'm trying to create a script that will superimpose text on an image.
I didn't find any great examples out there on how this can be done (I
presume using PIL is necessary), do you know of any examples?
Thanks,

Morten


Hi,

something like this?

###
from PIL import Image, ImageFont, ImageDraw
import sys

im = Image.open(YOUR_IMAGE_HERE)
idraw = ImageDraw.Draw(im)
idraw.text((1,1),"Hello", fill=128)
im.save(YOUR_NEW_IMAGE_HERE, IMAGE_TYPE)
###

HtH, Roland
Jul 18 '05 #2

P: n/a
Yes, something like that. I was a bit confused when it came to using
truetype fonts, but that was straightforward enough (just pass font
objects to the text method). :)

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.