程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python code for rotating pictures

編輯:Python
# rotate an image counter-clockwise using the PIL image library
free from: http://www.pythonware.com/products/pil/index.htm
make sure to install PIL after your regular python package is installed
import Image
open an image file (.bmp,.jpg,.png,.gif)
change image filename to something you have in the working folder
im1 = Image.open("Donald.gif")
rotate 60 degrees counter-clockwise
im2 = im1.rotate(60)
brings up the modified image in a viewer, simply saves the image as
a bitmap to a temporary file and calls viewer associated with .bmp
make certain you have an image viewer associated with this file type
im2.show()
save the rotated image as d.gif to the working folder
you can save in several different image formats, try d.jpg or d.png
PIL is pretty powerful stuff and figures it out from the extension
im2.save("d.gif")</pre> 

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved