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英语单词测试小程序代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 爬取了扇贝英语网,并制作了一个...

pandas数据框,统计某列数据对应的个数方法

pandas数据框,统计某列数据对应的个数方法

现在要解决的问题如下: 我们有一个数据的表 第7列有许多数字,并且是用逗号分隔的,数字又有一个对应的关系: 我们要得到第7列对应关系的统计,就是每一行的第7列a有多少个,b有多少个...

python实现自动获取IP并发送到邮箱

树莓派没有显示器,而不想设置固定IP,因为要随身携带外出,每个网络环境可能网段不一样。因此想用python写个脚本,让树莓派开机后自动获取本机ip,并且自动发送到我指定邮箱。(完整源码)...

Python3.7 读取 mp3 音频文件生成波形图效果

Python3.7 读取 mp3 音频文件生成波形图效果

测试环境为Windows 10 系统,Python3.7,转换需要提前安装pydub、ffmpeg,安装和加入环境变量配置方法自行解决,至于缺少的包直接 pip install xx 搞...

详解Numpy数组转置的三种方法T、transpose、swapaxes

详解Numpy数组转置的三种方法T、transpose、swapaxes

Numpy是高性能科学计算和数据分析的基础包,里面包含了许多对数组进行快速运算的标准数学函数,掌握这些方法,能摆脱数据处理时的循环。 1.首先数组转置(T) 创建二维数组data如下:...