Categories: Python | S60 | Code Examples | How To
This page was last modified 05:34, 29 April 2008.
How to edit an image
From Forum Nokia Wiki
This article describes how to manipulate images in PyS60.
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()
Here is the result for the example above:
The initial image The resulting image
See also: How to add text to an image
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Transparent background for image using S60 emulator | emerge | Mobile Java Media (Graphics & Sounds) | 2 | 2007-08-29 21:07 |
| how to speed up Image.createImage | seanlks82 | Mobile Java General | 1 | 2006-11-10 11:17 |
| Downlaoding image from a server using socket | ummarbhutta | Mobile Java Networking & Messaging & Security | 5 | 2006-12-05 11:33 |
| Image creation from RecordStore | askii | Mobile Java General | 5 | 2005-09-10 13:12 |
| image resize | Liyo | Mobile Java General | 11 | 2007-09-18 06:34 |


