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批量修改文件后缀示例代码分享
Dec 24 Python
浅谈Python程序与C++程序的联合使用
Apr 07 Python
django开发之settings.py中变量的全局引用详解
Mar 29 Python
Python编程实现微信企业号文本消息推送功能示例
Aug 21 Python
Django admin美化插件suit使用示例
Dec 12 Python
python 将列表中的字符串连接成一个长路径的方法
Oct 23 Python
python验证身份证信息实例代码
May 06 Python
Python实现TCP探测目标服务路由轨迹的原理与方法详解
Sep 04 Python
python3实现单目标粒子群算法
Nov 14 Python
在Python中实现函数重载的示例代码
Dec 12 Python
python爬取天气数据的实例详解
Nov 20 Python
pandas 按日期范围筛选数据的实现
Feb 20 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
Wordpress 相册插件 NextGEN-Gallery 添加目录将中文转为拼音的解决办法
2010/12/29 PHP
PHP使用glob函数遍历目录或文件夹的方法
2014/12/16 PHP
PHP学习笔记(一):基本语法之标记、空白、和注释
2015/04/17 PHP
prototype 中文参数乱码解决方案
2009/11/09 Javascript
js怎么判断flash swf文件是否加载完毕
2014/08/14 Javascript
JavaScript中Number.MAX_VALUE属性的使用方法
2015/06/04 Javascript
jQuery实现的个性化返回底部与返回顶部特效代码
2015/10/30 Javascript
使用BootStrap和Metroui设计的metro风格微网站或手机app界面
2016/10/21 Javascript
JavaScript使用正则表达式获取全部分组内容的方法示例
2017/01/17 Javascript
JavaScript中正则表达式判断匹配规则及常用方法
2017/08/03 Javascript
js制作简单的音乐播放器的示例代码
2017/08/28 Javascript
JS设计模式之访问者模式定义与用法分析
2018/02/05 Javascript
ES6使用export和import实现模块化的方法
2018/09/10 Javascript
微信小程序进入广告实现代码实例
2019/09/19 Javascript
Vue中computed及watch区别实例解析
2020/08/01 Javascript
electron踩坑之dialog中的callback解决
2020/10/06 Javascript
[36:19]2018DOTA2亚洲邀请赛 小组赛 A组加赛 Newbee vs LGD
2018/04/03 DOTA
Python 比较两个数组的元素的异同方法
2017/08/17 Python
Python实现读取json文件到excel表
2017/11/18 Python
Python的对象传递与Copy函数使用详解
2019/12/26 Python
Python列表如何更新值
2020/05/27 Python
解决python 在for循环并且pop数组的时候会跳过某些元素的问题
2020/12/11 Python
日本非常有名的内衣丝袜品牌:GUNZE
2017/01/06 全球购物
购买美国制造的相框和画框架:Picture Frames
2018/08/14 全球购物
介绍一下javax.servlet.Servlet接口及其主要方法
2015/11/30 面试题
化验室技术员岗位职责
2013/12/24 职场文书
运动会解说词50字
2014/01/18 职场文书
中专生毕业个人鉴定
2014/02/26 职场文书
农民工工资支付承诺函
2014/03/31 职场文书
本科生导师推荐信范文
2014/05/18 职场文书
经济管理专业求职信
2014/06/09 职场文书
企业三严三实学习心得体会
2014/10/13 职场文书
基层党建工作简报
2015/07/21 职场文书
2016保送生自荐信范文
2016/01/29 职场文书
Nginx设置日志打印post请求参数的方法
2021/03/31 Servers
Python实战之大鱼吃小鱼游戏的实现
2022/04/01 Python