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


Posted in Python onMay 30, 2015

本文实例讲述了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下的Mysql模块MySQLdb安装详解
Apr 09 Python
在Python中操作字典之update()方法的使用
May 22 Python
Python while、for、生成器、列表推导等语句的执行效率测试
Jun 03 Python
python3.4用循环往mysql5.7中写数据并输出的实现方法
Jun 20 Python
Python实现将照片变成卡通图片的方法【基于opencv】
Jan 17 Python
Python实现正弦信号的时域波形和频谱图示例【基于matplotlib】
May 04 Python
python3实现名片管理系统
Nov 29 Python
使用python实现离散时间傅里叶变换的方法
Sep 02 Python
浅析python 定时拆分备份 nginx 日志的方法
Apr 27 Python
Python自定义sorted排序实现方法详解
Sep 18 Python
浅谈Python __init__.py的作用
Oct 28 Python
OpenCV-Python 实现两张图片自动拼接成全景图
Jun 11 Python
Python实现控制台输入密码的方法
May 29 #Python
python删除过期文件的方法
May 29 #Python
Python的Django框架中TEMPLATES项的设置教程
May 29 #Python
编写Python脚本把sqlAlchemy对象转换成dict的教程
May 29 #Python
Python fileinput模块使用实例
May 28 #Python
Python sys.argv用法实例
May 28 #Python
Python中exit、return、sys.exit()等使用实例和区别
May 28 #Python
You might like
叶罗丽:为什么大家对颜冰这对CP非常关心,却对金茉两人十分冷漠
2020/03/17 国漫
程序员编程十条戒律
2009/07/09 PHP
PHP入门经历和学习过程分享
2014/04/11 PHP
Yii中srbac权限扩展模块工作原理与用法分析
2016/07/14 PHP
Zend Framework入门应用实例详解
2016/12/11 PHP
js常用函数 不错
2006/09/08 Javascript
Javascript笔记一 js以及json基础使用说明
2010/05/22 Javascript
jquery简单瀑布流实现原理及ie8下测试代码
2013/01/23 Javascript
JS中产生标识符方式的演变
2015/06/12 Javascript
JS截取与分割字符串常用技巧总结
2015/11/10 Javascript
原生js制作日历控件实例分享
2016/04/06 Javascript
利用Node.JS实现邮件发送功能
2016/10/21 Javascript
vue.js初学入门教程(2)
2016/11/07 Javascript
AngularJS实现ajax请求的方法
2016/11/22 Javascript
基于Layui自定义模块的使用方法详解
2019/09/14 Javascript
ant-design-vue 快速避坑指南(推荐)
2020/01/21 Javascript
浅谈鸿蒙 JavaScript GUI 技术栈
2020/09/17 Javascript
微信小程序入门之绘制时钟
2020/10/22 Javascript
[51:06]2018DOTA2亚洲邀请赛3月29日 小组赛A组 KG VS Liquid
2018/03/30 DOTA
[14:24]Optic Gaming vs PSG LGD BO3
2018/06/07 DOTA
[01:11:21]DOTA2-DPC中国联赛 正赛 VG vs Elephant BO3 第一场 3月6日
2021/03/11 DOTA
Python内置的字符串处理函数整理
2013/01/29 Python
python使用xmlrpc实例讲解
2013/12/17 Python
python使用sorted函数对列表进行排序的方法
2015/04/04 Python
python实现从文件中读取数据并绘制成 x y 轴图形的方法
2018/10/14 Python
Python实现微信自动好友验证,自动回复,发送群聊链接方法
2019/02/21 Python
python设置环境变量的原因和方法
2019/06/24 Python
python处理RSTP视频流过程解析
2020/01/11 Python
Python ellipsis 的用法详解
2020/11/20 Python
HTML5中的nav标签学习笔记
2016/06/24 HTML / CSS
实习教师自我鉴定
2013/12/09 职场文书
幼教简历自我评价
2014/01/28 职场文书
出纳工作检讨书
2014/10/18 职场文书
钢铁是怎样炼成的读书笔记
2015/06/29 职场文书
mysql自增长id用完了该怎么办
2022/02/12 MySQL
一文弄懂MySQL中redo log与binlog的区别
2022/02/15 MySQL