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

yipeiwu_com5年前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实现标签云算法

标签云(Tag Cloud)常见于各种博客站点中,标签有利于网站内容分类,还可以用于相关性内容推荐。近日笔者有空把个人的开源博客Django_blog添加了一个新功能--标签云。 实现...

tensorflow如何批量读取图片

tensorflow如何批量读取图片

本文实例为大家分享了tensorflow如何批量读取图片的具体代码,供大家参考,具体内容如下 代码: import tensorflow as tf import os de...

Python 包含汉字的文件读写之每行末尾加上特定字符

      最近,接手的项目里,提供的数据文件格式简直让人看不下去,使用pandas打不开,一直是io error.仔细查看,发现文件中...

selenium python 实现基本自动化测试的示例代码

selenium python 实现基本自动化测试的示例代码

安装selenium 打开命令控制符输入:pip install -U selenium 火狐浏览器安装firebug:www.firebug.com,调试所有网站语言,调试功能 Sel...

python找出完数的方法

如下所示: # -*- coding: utf-8 -*- # 要求:用python方法找出1000以内的所有完数,并输出。 def f(n): list = [] for i...