python简单实现旋转图片的方法

yipeiwu_com6年前Python基础

本文实例讲述了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")

希望本文所述对大家的Python程序设计有所帮助。

相关文章

python判断单向链表是否包括环,若包含则计算环入口的节点实例分析

python判断单向链表是否包括环,若包含则计算环入口的节点实例分析

本文实例讲述了python判断单向链表是否包括环,若包含则计算环入口的节点。分享给大家供大家参考,具体如下: 关于数据结构相关的面试题,经常会问到链表中是否存在环结构的判断,下图就是存在...

Django ORM 练习题及答案

1.modles中表结构 #出版社 class Publisher(models.Model): name = models.CharField(max_length=32)...

安装Python和pygame及相应的环境变量配置(图文教程)

安装Python和pygame及相应的环境变量配置(图文教程)

Hello,Everyone! Python是个好东西!好吧,以黎某人这寒碜的赞美之词,实在上不了台面,望见谅。那我们直接来上干货吧。 第一步:下载Python安装包https://ww...

Python中的map()函数和reduce()函数的用法

Python中的map()函数和reduce()函数的用法

Python内建了map()和reduce()函数。 如果你读过Google的那篇大名鼎鼎的论文“MapReduce: Simplified Data Processing on Lar...

python-Web-flask-视图内容和模板知识点西宁街

基本使用 #设置cookie值 @app.route('/set_cookie') def set_cookie(): response = make_response("...