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的web框架中配置app的教程

有了Web框架和ORM框架,我们就可以开始装配App了。 通常,一个Web App在运行时都需要读取配置文件,比如数据库的用户名、口令等,在不同的环境中运行时,Web App可以通过读取...

Django forms表单 select下拉框的传值实例

今儿继续做项目,学习了Django的forms生成前端的代码。 forms.py class SignupForm(forms.Form): username = forms.C...

python取代netcat过程分析

首先解释几个概念: TCP:TCP是因特网中的传输层协议,使用三次握手协议建立连接。 IP:Internet Protocol协议的英文名直译就是:因特网协议。 UDP:和TCP一...

python+flask实现API的方法

python+flask实现API的方法

本文为大家分享了python+flask实现API的具体方法,供大家参考,具体内容如下 Flask 框架 #-*-coding:utf-8-*- #pip install f...

flask框架视图函数用法示例

本文实例讲述了flask框架视图函数用法。分享给大家供大家参考,具体如下: flask框架 视图函数当中 各种实用情况简单配置 1 建立连接 2 路由参数 3 返回网络状态码 4 自定义...