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

yipeiwu_com6年前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 spyder中读取txt为图片的方法

有时候需要将一个环境中的图片可视化,但是可能这个环境下不方便,因此需要将这个环境下的图像数据保存下来,然后在另一个环境下查看,比如,有一个图像数据,image.txt,里面的数据是图像的...

python elasticsearch环境搭建详解

windows下载zip linux下载tar 下载地址:https://www.elastic.co/downloads/elasticsearch 解压后运行:bin/elast...

利用Python将每日一句定时推送至微信的实现方法

利用Python将每日一句定时推送至微信的实现方法

前言 前几天在网上看到一篇文章《教你用微信每天给女票说晚安》,感觉很神奇的样子,随后研究了一下,构思的确是巧妙。好,那就开始动工吧!服务器有了,Python环境有了,IDE打开了...然...

微信跳一跳python辅助脚本(总结)

微信跳一跳python辅助脚本(总结)

这段时间微信跳一跳这个游戏非常火爆,但是上分又非常的难,对于程序员来说第一个念头就是通过写一个辅助脚本外挂让上分变的容易,python现在比较火,我们一起来以python语言为基础总结以...

python编写简单端口扫描器

python编写简单端口扫描器

本文实例为大家分享了python编写简单端口扫描器的具体代码,供大家参考,具体内容如下 直接放代码 此代码只支持扫描域名,要扫描IP请自己修改 from socket import...