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

作者:皮蛋 时间:2021-06-09 08:29:11 

本文实例讲述了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,图片
0
投稿

猜你喜欢

  • python调试模块ipdb详解

    2021-11-05 19:59:01
  • python 正则式 概述及常用字符

    2023-01-14 14:50:54
  • asp如何用JMail同时给多人发信?

    2010-06-12 12:52:00
  • SQL语句练习实例之一——找出最近的两次晋升日期与工资额

    2011-10-24 20:16:42
  • Python实现视频下载功能

    2022-04-06 13:42:14
  • Python如何对齐字符串

    2023-05-30 01:21:11
  • python不等于运算符的具体使用

    2022-03-29 11:21:21
  • IE6终极备忘单——对IE6单独兼容[译]

    2010-01-21 18:34:00
  • 浅析python的Lambda表达式

    2021-11-16 23:51:19
  • python web框架中实现原生分页

    2021-05-15 12:25:42
  • python3 读取Excel表格中的数据

    2021-01-14 23:03:42
  • 详解python中index()、find()方法

    2021-02-25 02:38:59
  • Python学习之虚拟环境原理详解

    2023-02-12 16:45:52
  • JS分割字符串并放入数组的函数

    2023-08-05 15:31:03
  • 简单有效上手Python3异步asyncio问题

    2022-01-14 02:28:34
  • 基于pandas向csv添加新的行和列

    2021-11-29 02:28:56
  • Python实现21点小游戏的示例代码

    2022-06-14 06:32:10
  • 基于Python编写简单实用的日志装饰器

    2022-10-09 01:21:51
  • caffe的python接口生成配置文件学习

    2023-07-09 04:46:41
  • Python如何利用%操作符格式化字符串详解

    2022-07-17 14:08:39
  • asp之家 网络编程 m.aspxhome.com