Creating text on images

M

morphex

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
 
R

Roland Heiber

morphex said:
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
 
M

morphex

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). :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top