×
Namespaces

Variants
Actions
Revision as of 22:20, 24 September 2009 by fasttrack (Talk | contribs)

Archived:How to add a text to an image in PySymbian

From Nokia Developer Wiki
Jump to: navigation, search
{{{width}}}


Article Metadata
Tested with
Devices(s): Nokia N96
Compatibility
Platform(s): S60 2nd Edition, S60 3rd Edition
Article
Keywords: graphics, image
Created: (28 Apr 2008)
Last edited: fasttrack (24 Sep 2009)

Overview

This article contains code snippets showing how text can be added to an image or a photo in Python.

Code

How to add text to a blank image

# import module
from graphics import *
 
# Open new blank Image of given size
bg=Image.new((240,240))
 
# Write text at given position
bg.text((30,30), u"Text", font="title")
 
# Save the new Image
bg.save("C:\\TextOnImage.jpg", quality=100)

How to add text to a photo

# import module
from graphics import *
 
# Open an existing Image
photo=Image.open("c:\\myphoto.jpg")
 
# Write text at given position
photo.text((100,80), u"Green Circle", font="normal")
 
# Save the new Image
photo.save("c:\\TextOnPhoto.jpg")

Postconditions

We obtain following resulting images from above code

Text on a Blank Image
Text on existing photo of a Green Circle

Related Links

How to edit an image

112 page views in the last 30 days.
×