python实现图片变亮或者变暗的方法


Posted in Python onJune 01, 2015

本文实例讲述了python实现图片变亮或者变暗的方法。分享给大家供大家参考。具体实现方法如下:

import Image
# open an image file (.jpg or.png) you have in the working folder
im1 = Image.open("angelababy.jpg")
# multiply each pixel by 0.9 (makes the image darker)
# works best with .jpg and .png files, darker < 1.0 < lighter
# (.bmp and .gif files give goofy results)
# note that lambda is akin to a one-line function
im2 = im1.point(lambda p: p * 0.5)
# 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 associated an image viewer with this file type
im2.show()
# save modified image to working folder as Audi2.jpg
im2.save("angelababy2.jpg")

运行效果如下所示:

python实现图片变亮或者变暗的方法

希望本文所述对大家的Python程序设计有所帮助。

Python 相关文章推荐
Python实现根据指定端口探测服务器/模块部署的方法
Aug 25 Python
Python中的Matplotlib模块入门教程
Apr 15 Python
Python进阶之尾递归的用法实例
Jan 31 Python
Python实现matplotlib显示中文的方法详解
Feb 06 Python
人生苦短我用python python如何快速入门?
Mar 12 Python
python函数式编程学习之yield表达式形式详解
Mar 25 Python
详解python单元测试框架unittest
Jul 02 Python
python多进程重复加载的解决方式
Dec 13 Python
Python动态强类型解释型语言原理解析
Mar 25 Python
使用python检查yaml配置文件是否符合要求
Apr 09 Python
Keras中的多分类损失函数用法categorical_crossentropy
Jun 11 Python
python 窃取摄像头照片的实现示例
Jan 08 Python
wxPython中listbox用法实例详解
Jun 01 #Python
在Python的Django框架下使用django-tagging的教程
May 30 #Python
使用url_helper简化Python中Django框架的url配置教程
May 30 #Python
在Python的Django框架中simple-todo工具的简单使用
May 30 #Python
Python中Django框架下的staticfiles使用简介
May 30 #Python
简单介绍Python的Django框架的dj-scaffold项目
May 30 #Python
Python的Django框架中settings文件的部署建议
May 30 #Python
You might like
PHP 内存缓存加速功能memcached安装与用法
2009/09/03 PHP
php微信公众号开发之欢迎老朋友
2018/10/20 PHP
一个很简单的办法实现TD的加亮效果.
2006/06/29 Javascript
js小技巧--自动隐藏红叉叉
2007/08/13 Javascript
JS 动态获取节点代码innerHTML分析 [IE,FF]
2009/11/30 Javascript
文本域光标操作的jQuery扩展分享
2014/03/10 Javascript
jQuery中noconflict函数的实现原理分解
2015/02/03 Javascript
jQuery实现的动态伸缩导航菜单实例
2015/05/07 Javascript
jquery插件jquery.beforeafter.js实现左右拖拽分隔条对比图片的方法
2015/08/07 Javascript
简单谈谈关于 npm 5.0 的新坑
2017/06/08 Javascript
Vue.js实例方法之生命周期详解
2017/07/03 Javascript
小程序实现带年月选取效果的日历
2018/06/27 Javascript
vue中的router-view组件的使用教程
2018/10/23 Javascript
JavaScript根据json生成html表格的示例代码
2018/10/24 Javascript
Vue的click事件防抖和节流处理详解
2019/11/13 Javascript
[02:29]大剑、皮鞭、女装,这届DOTA2勇士令状里都有
2020/07/17 DOTA
在Python中使用cookielib和urllib2配合PyQuery抓取网页信息
2015/04/25 Python
python如何实现excel数据添加到mongodb
2015/07/30 Python
Python tornado队列示例-一个并发web爬虫代码分享
2018/01/09 Python
python实现excel读写数据
2021/03/02 Python
python 除法保留两位小数点的方法
2018/07/16 Python
Python解析Excle文件中的数据方法
2018/10/23 Python
python提取包含关键字的整行数据方法
2018/12/11 Python
python 实现分页显示从es中获取的数据方法
2018/12/26 Python
Django Serializer HiddenField隐藏字段实例
2020/03/31 Python
Python 实现键盘鼠标按键模拟
2020/11/18 Python
英国IT硬件供应商,定制游戏PC:Mesh Computers
2019/03/28 全球购物
中专生职业生涯规划书范文
2013/12/29 职场文书
幼儿园教师奖惩制度
2014/02/01 职场文书
大学班级干部的自我评价分享
2014/02/10 职场文书
税务干部鉴定材料
2014/02/11 职场文书
2014年大学生四年规划书范文
2014/04/03 职场文书
房屋所有权证明
2014/10/20 职场文书
jQuery实现影院选座订座效果
2021/04/13 jQuery
Python爬虫基础之初次使用scrapy爬虫实例
2021/06/26 Python
Redis官方可视化工具RedisInsight安装使用教程
2022/04/19 Redis