Namespaces

Variants
Actions

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 over the next few weeks. 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
CompatibilityArticle
Keywords: graphics, image
Created: bogdan.galiceanu (28 Mar 2008)
Last edited: hamishwillee (31 May 2013)

Overview

This article describes how to manipulate images in PySymbian.

Code snippet

import appuifw, e32
from graphics import *
 
#Define the exit function:
app_lock=e32.Ao_lock()
def quit():app_lock.signal()
appuifw.app.exit_key_handler=quit
 
#We open the image
img=Image.open("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)
img=img.transpose(ROTATE_90)
#Other ways of transposing are:
#FLIP_LEFT_RIGHT, FLIP_TOP_BOTTOM, ROTATE_180, ROTATE_270
#Note that rotations are counterclockwise
 
#Finally, we save the new image
img.save("C:\\i2.jpg", quality=100)
 
#Tell the application not to close until the user tells it to:
app_lock.wait()

Postconditions

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.
60 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×