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程序设计有所帮助。

相关文章

django框架中ajax的使用及避开CSRF 验证的方式详解

django框架中ajax的使用及避开CSRF 验证的方式详解

本文实例讲述了django框架中ajax的使用及避开CSRF 验证的方式。分享给大家供大家参考,具体如下: ajax(Asynchronous Javascript And Xml) 异...

对Python random模块打乱数组顺序的实例讲解

对Python random模块打乱数组顺序的实例讲解

在我们使用一些数据的过程中,我们想要打乱数组内数据的顺序但不改变数据本身,可以通过改变索引值来实现,也就是将索引值重新随机排列,然后生成新的数组。功能主要由python中random模块...

Anaconda2下实现Python2.7和Python3.5的共存方法

Anaconda2下实现Python2.7和Python3.5的共存方法

Anaconda 本质上是一个软件发行版,包含了 conda、Python 等 180 多个科学包及其依赖项。 因为包含了大量的科学包,Anaconda 的下载文件比较大(约 500 M...

python框架django基础指南

Django简介: Django是一个开放源代码的Web应用框架,由Python写成。采用了MVC的框架模式,即模型M,视图V和控制器C。不过在Django实际使用中,Django更关注...

Python排序搜索基本算法之希尔排序实例分析

Python排序搜索基本算法之希尔排序实例分析

本文实例讲述了Python排序搜索基本算法之希尔排序。分享给大家供大家参考,具体如下: 希尔排序是插入排序的扩展,通过允许非相邻的元素进行交换来提高执行效率。希尔排序最关键的是选择步长,...