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的Django框架中if标签的相关使用
Jul 15 Python
Python找出9个连续的空闲端口
Feb 01 Python
为什么入门大数据选择Python而不是Java?
Mar 07 Python
Python实现iOS自动化打包详解步骤
Oct 03 Python
详解python中list的使用
Mar 15 Python
python主线程与子线程的结束顺序实例解析
Dec 17 Python
Python GUI自动化实现绕过验证码登录
Jan 10 Python
利用Python脚本实现自动刷网课
Feb 03 Python
20行Python代码实现视频字符化功能
Apr 13 Python
python属于哪种语言
Aug 16 Python
python Gabor滤波器讲解
Oct 26 Python
详解Python3.8+PyQt5+pyqt5-tools+Pycharm配置详细教程
Nov 02 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
thinkphp中连接oracle时封装方法无法用的解决办法
2013/06/17 PHP
php中PDO方式实现数据库的增删改查
2015/05/17 PHP
很可爱的输入框
2008/08/03 Javascript
js中方法重载如何实现?以及函数的参数问题
2013/08/01 Javascript
Node.js开源应用框架HapiJS介绍
2015/01/14 Javascript
JavaScript中使用Math.PI圆周率属性的方法
2015/06/14 Javascript
详解AngularJS中的表格使用
2015/06/16 Javascript
javascript实现列表滚动的方法
2015/07/30 Javascript
简单谈谈JavaScript的同步与异步
2015/12/31 Javascript
node.js中module.exports与exports用法上的区别
2016/09/02 Javascript
JS实现针对给定时间的倒计时功能示例
2017/04/11 Javascript
Angular 4依赖注入学习教程之FactoryProvider配置依赖对象(五)
2017/06/04 Javascript
详解微信小程序设置底部导航栏目方法
2017/06/29 Javascript
JavaScript实现QQ列表展开收缩扩展功能
2017/10/30 Javascript
使用JavaScript生成罗马字符的实例代码
2018/06/08 Javascript
vue-cli2 构建速度优化的实现方法
2019/01/08 Javascript
JavaScript之Blob对象类型的具体使用方法
2019/11/29 Javascript
解决Vue + Echarts 使用markLine标线(precision精度问题)
2020/07/20 Javascript
python 装饰器功能以及函数参数使用介绍
2012/01/27 Python
Python matplotlib画图实例之绘制拥有彩条的图表
2017/12/28 Python
用python实现刷点击率的示例代码
2019/02/21 Python
python 列表中[ ]中冒号‘:’的作用
2019/04/30 Python
在 Python 中使用 7zip 备份文件的操作
2020/12/11 Python
Python3使用Selenium获取session和token方法详解
2021/02/16 Python
CSS3 滤镜 webkit-filter详细介绍及使用方法
2012/12/27 HTML / CSS
澳大利亚宠物商店:Petbarn
2017/11/18 全球购物
Lookfantastic希腊官网:英国知名美妆购物网站
2018/09/15 全球购物
lululemon美国官网:瑜伽服+跑步装备
2018/11/16 全球购物
在线吉他课程,学习如何弹吉他:Fender Play
2019/02/28 全球购物
计算机应用专业应届毕业生中文求职信范文
2013/11/29 职场文书
开展党的群众路线教育实践活动方案
2014/02/05 职场文书
小学国旗下的演讲稿
2014/08/28 职场文书
2015年安全保卫工作总结
2015/05/14 职场文书
2015初中政教处工作总结
2015/07/21 职场文书
python​格式化字符串
2022/04/20 Python