Archived:How to edit an image in PySymbian
Aquivado: 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)
Acredita-se que este artigo ainda seja válido no contexto original (quando ele foi escrito)
Article Metadata
Tested with
Devices(s): Nokia N96
Compatibility
Platform(s): S60 2nd Edition, S60 3rd Edition
Article
Keywords: graphics, image
Created: bogdan.galiceanu
(28 Mar 2008)
Last edited: hamishwillee
(08 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:
The initial image The resulting image
See also: How to add a text to an image




28 Sep
2009
28 Sep
2009