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+matplotlib演示电偶极子实例代码
Jan 12 Python
使用Python爬了4400条淘宝商品数据,竟发现了这些“潜规则”
Mar 23 Python
机器学习之KNN算法原理及Python实现方法详解
Jul 09 Python
python selenium 弹出框处理的实现
Feb 26 Python
python requests指定出口ip的例子
Jul 25 Python
Python Django 实现简单注册功能过程详解
Jul 29 Python
基于python3 的百度图片下载器的实现代码
Nov 05 Python
Python内置异常类型全面汇总
May 28 Python
Python字符串三种格式化输出
Sep 17 Python
Pytorch中Softmax与LogSigmoid的对比分析
Jun 05 Python
Python os和os.path模块详情
Apr 02 Python
python数字图像处理:图像的绘制
Jun 28 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
DedeCms模板安装/制作概述
2007/03/11 PHP
Yii使用CLinkPager分页实例详解
2014/07/23 PHP
PHP使用递归方式列出当前目录下所有文件的方法
2015/06/02 PHP
PHP多进程编程实例详解
2017/07/19 PHP
jQuery+CSS 实现的超Sexy下拉菜单
2010/01/17 Javascript
jquery实现带复选框的表格行选中删除时高亮显示
2013/08/01 Javascript
框架页面高度自动刷新的Javascript脚本
2013/11/01 Javascript
滚动条响应鼠标滑轮事件实现上下滚动的js代码
2014/06/30 Javascript
js实现九宫格图片半透明渐显特效的方法
2015/02/16 Javascript
JavaScript通过join函数连接数组里所有元素的方法
2015/03/20 Javascript
JavaScript检测弹出窗口是否已经关闭的方法
2015/03/24 Javascript
javascript 使用正则test( )第一次是 true,第二次是false
2017/02/22 Javascript
Angularjs过滤器实现动态搜索与排序功能示例
2017/12/13 Javascript
基于vue循环列表时点击跳转页面的方法
2018/08/31 Javascript
详解vue服务端渲染浏览器端缓存(keep-alive)
2018/10/12 Javascript
Vue项目实现换肤功能的一种方案分析
2019/08/28 Javascript
jquery实现加载更多"转圈圈"效果(示例代码)
2020/11/09 jQuery
一文秒懂nodejs中的异步编程
2021/01/28 NodeJs
windows下Virtualenvwrapper安装教程
2017/12/13 Python
Python实现的随机森林算法与简单总结
2018/01/30 Python
PyTorch实现更新部分网络,其他不更新
2019/12/31 Python
opencv python图像梯度实例详解
2020/02/04 Python
python GUI框架pyqt5 对图片进行流式布局的方法(瀑布流flowlayout)
2020/03/12 Python
pyqt5实现井字棋的示例代码
2020/12/07 Python
绝对令人的惊叹的CSS3折叠效果(3D效果)整理
2012/12/30 HTML / CSS
Ralph Lauren拉夫·劳伦美国官网:带有浓郁美国气息的高品味时装品牌
2017/11/01 全球购物
同学会邀请书大全
2014/01/12 职场文书
留学自荐信写作方法
2014/01/27 职场文书
2015年建筑工作总结报告
2015/05/04 职场文书
太空授课观后感
2015/06/17 职场文书
主婚人致辞精选
2015/07/28 职场文书
小学语文教师研修感悟
2015/11/18 职场文书
MySQL索引篇之千万级数据实战测试
2021/04/05 MySQL
Python实现文本文件拆分写入到多个文本文件的方法
2021/04/18 Python
Netty分布式客户端接入流程初始化源码分析
2022/03/25 Java/Android
Redis基本数据类型List常用操作命令
2022/06/01 Redis