Created
June 20, 2012 14:22
-
-
Save tommi-lew/2960141 to your computer and use it in GitHub Desktop.
Code snippets on using PIL for overlaying text over image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import ImageFont | |
from PIL import Image | |
from PIL import ImageDraw | |
from StringIO import StringIO | |
font = ImageFont.load_default() | |
input = StringIO(self.request.get("img")) | |
img = Image.open(input) | |
draw = ImageDraw.Draw(img) | |
draw.text((0, 0),self.request.get('content'),(255,255,0),font=font) | |
draw = ImageDraw.Draw(img) | |
output = StringIO() | |
img.save(output, format="JPEG") | |
greeting.avatar = db.Blob(output.getvalue()) | |
output.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment