User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 402,640 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,222 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Jan 28th, 2005
Views: 4,772
Another application of the Python Image Library (PIL). This time we are loading an image and rotate it counterclockwise by a specified number of degrees. The image is shown rotated and then saved to the working folder. PIL handles a fair amount of image file formats easily.
python Syntax | 2 stars
  1. # rotate an image counter-clockwise using the PIL image library
  2. # free from: http://www.pythonware.com/products/pil/index.htm
  3. # make sure to install PIL after your regular python package is installed
  4.  
  5. import Image
  6.  
  7. # open an image file (.bmp,.jpg,.png,.gif)
  8. # change image filename to something you have in the working folder
  9. im1 = Image.open("Donald.gif")
  10.  
  11. # rotate 60 degrees counter-clockwise
  12. im2 = im1.rotate(60)
  13.  
  14. # brings up the modified image in a viewer, simply saves the image as
  15. # a bitmap to a temporary file and calls viewer associated with .bmp
  16. # make certain you have an image viewer associated with this file type
  17. im2.show()
  18.  
  19. # save the rotated image as d.gif to the working folder
  20. # you can save in several different image formats, try d.jpg or d.png
  21. # PIL is pretty powerful stuff and figures it out from the extension
  22. im2.save("d.gif")
  23.  
Comments (Newest First)
vegaseat | Kickbutt Moderator | May 20th, 2005
The Python Image Library (PIL) is now available for Python24.
Download and instal
PIL-1.1.5.win32-py2.4.exe [533k]
from
http://effbot.org/downloads/#imaging
vegaseat | Kickbutt Moderator | Mar 20th, 2005
At this point PIL is only available for Python v2.3, sorry! I hope this will change soon.
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 2:22 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC