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实现登陆知乎获得个人收藏并保存为word文件
Mar 16 Python
Python编写百度贴吧的简单爬虫
Apr 02 Python
探索Python3.4中新引入的asyncio模块
Apr 08 Python
举例详解Python中yield生成器的用法
Aug 05 Python
Python读大数据txt
Mar 28 Python
python互斥锁、加锁、同步机制、异步通信知识总结
Feb 11 Python
django 消息框架 message使用详解
Jul 22 Python
python中如何实现将数据分成训练集与测试集的方法
Sep 13 Python
Python 根据数据模板创建shapefile的实现
Nov 26 Python
django的模型类管理器——数据库操作的封装详解
Apr 01 Python
Python3实现个位数字和十位数字对调, 其乘积不变
May 03 Python
浅析python函数式编程
Sep 26 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
java EJB 加密与解密原理的一个例子
2008/01/11 PHP
php中出现空白页的原因及解决方法汇总
2014/07/08 PHP
ThinkPHP中html:list标签用法分析
2016/01/09 PHP
Joomla简单判断用户是否登录的方法
2016/05/04 PHP
PHP版微信小店接口开发实例
2016/11/12 PHP
PHP中__set()实例用法和基础讲解
2019/07/23 PHP
javascript新建标签,判断键盘输入,以及判断焦点(示例代码)
2013/11/25 Javascript
JavaScript使用FileSystemObject对象写入文本文件内容的方法
2015/08/05 Javascript
设置jQueryUI DatePicker默认语言为中文
2016/06/04 Javascript
深入浅析JS是按值传递还是按引用传递(推荐)
2016/09/18 Javascript
JS实现表单多文件上传样式美化支持选中文件后删除相关项
2016/09/30 Javascript
vue :src 文件路径错误问题的解决方法
2018/05/15 Javascript
微信小程序map组件结合高德地图API实现wx.chooseLocation功能示例
2019/01/23 Javascript
解决Antd Table组件表头不对齐的问题
2020/10/27 Javascript
Python编程中运用闭包时所需要注意的一些地方
2015/05/02 Python
python选择排序算法实例总结
2015/07/01 Python
Python Requests 基础入门
2016/04/07 Python
带你了解python装饰器
2017/06/15 Python
Python中对象的引用与复制代码示例
2017/12/04 Python
python调用c++ ctype list传数组或者返回数组的方法
2019/02/13 Python
python爬虫简单的添加代理进行访问的实现代码
2019/04/04 Python
PyQt5 如何让界面和逻辑分离的方法
2020/03/24 Python
纯CSS实现预加载动画效果
2017/09/06 HTML / CSS
HTML5声音录制/播放功能的实现代码
2018/05/03 HTML / CSS
friso美素佳儿官方海外旗舰店:荷兰原产原罐
2017/07/03 全球购物
美国汽车零部件和配件网站:CarParts
2019/03/13 全球购物
浅谈react路由传参的几种方式
2021/03/23 Javascript
写给女朋友的道歉信
2014/01/08 职场文书
学校门卫管理制度
2014/01/30 职场文书
公司管理建议书范文
2014/03/12 职场文书
2014保险公司内勤工作总结
2014/12/16 职场文书
2015年六一儿童节活动总结
2015/02/11 职场文书
解除劳动合同通知书范本
2015/04/16 职场文书
我的法兰西岁月观后感
2015/06/09 职场文书
css实现文章分割线样式的多种方法总结
2021/04/21 HTML / CSS
GoLang中生成UUID唯一标识的实现
2021/05/08 Golang