Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:How to edit an image in PySymbian

From Wiki
Jump to: navigation, search

Archived.pngAquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

Acredita-se que este artigo ainda seja válido no contexto original (quando ele foi escrito)

Article Metadata
Tested with
Devices(s): Nokia N96
Keywords: graphics, image
Created: bogdan.galiceanu (28 Mar 2008)
Last edited: hamishwillee (31 May 2013)


This article describes how to manipulate images in PySymbian.

Code snippet

import appuifw, e32
from graphics import *
#Define the exit function:
def quit():app_lock.signal()
#We open the image"C:\\i.jpg")
#We can see its current size
print img.size
#Now we resize it:
img=img.resize((240,240), keepaspect=0)
#The target size is a tuple containing the new dimensions in pixles
#keepaspect is optional. If 1, the image's current aspect ratio is maintained
#The image can also be transposed (here we rotate it by 90 degrees)
#Other ways of transposing are:
#Note that rotations are counterclockwise
#Finally, we save the new image"C:\\i2.jpg", quality=100)
#Tell the application not to close until the user tells it to:


Here is the result for the example above:

InitialImg.jpg          FinalImg.jpg

The initial image                                                                                                               The resulting image

See also: How to add a text to an image

This page was last modified on 31 May 2013, at 01:03.
46 page views in the last 30 days.