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框架中的QuerySets
Apr 20 Python
centos6.7安装python2.7.11的具体方法
Jan 16 Python
Python做简单的字符串匹配详解
Mar 21 Python
基于python3 类的属性、方法、封装、继承实例讲解
Sep 19 Python
使用Pyinstaller的最新踩坑实战记录
Nov 08 Python
Django中反向生成models.py的实例讲解
May 30 Python
CentOS下Python3的安装及创建虚拟环境的方法
Nov 28 Python
使用Python和Prometheus跟踪天气的使用方法
May 06 Python
TensorFlow tensor的拼接实例
Jan 19 Python
python函数enumerate,operator和Counter使用技巧实例小结
Feb 22 Python
Python pip install如何修改默认下载路径
Apr 29 Python
PyTorch dropout设置训练和测试模式的实现
May 27 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
星际争霸中的热键
2020/03/04 星际争霸
使用adodb lite解决问题
2006/12/31 PHP
PHP利用MySQL保存session的实现思路及示例代码
2014/09/09 PHP
php简单防盗链实现方法
2015/07/29 PHP
CodeIgniter框架钩子机制实现方法【hooks类】
2018/08/21 PHP
基于thinkphp6.0的success、error实现方法
2019/11/05 PHP
php实现对短信验证码发送次数的限制实例讲解
2021/03/04 PHP
GreyBox技术总结(转)
2010/11/23 Javascript
jQuery之尺寸调整组件的深入解析
2013/06/19 Javascript
点击弹出层外区域关闭弹出层jquery特效示例
2013/08/25 Javascript
Visual Studio中js调试的方法图解
2014/06/30 Javascript
手机端转盘抽奖代码分享
2015/09/10 Javascript
JavaScript构造函数详解
2015/12/27 Javascript
Google 地图类型详解及示例代码
2016/08/06 Javascript
jQuery 翻页组件yunm.pager.js实现div局部刷新的思路
2016/08/11 Javascript
vuejs开发组件分享之H5图片上传、压缩及拍照旋转的问题处理
2017/03/06 Javascript
Node.js设置CORS跨域请求中多域名白名单的方法
2017/03/28 Javascript
nodejs动态创建二维码的方法
2017/08/12 NodeJs
python获得图片base64编码示例
2014/01/16 Python
python常用函数详解
2016/09/13 Python
在flask中使用python-dotenv+flask-cli自定义命令(推荐)
2020/01/05 Python
python画图常规设置方式
2020/03/05 Python
Django路由层URLconf作用及原理解析
2020/09/24 Python
使用JS+CSS3技术:让你的名字动起来
2013/04/27 HTML / CSS
html table呈现个人简历以及单元格宽度失效的问题解决
2021/01/22 HTML / CSS
CK美国官网:Calvin Klein
2016/08/26 全球购物
EJB需直接实现它的业务接口或Home接口吗,请简述理由
2016/11/23 面试题
教师绩效工资方案
2014/02/01 职场文书
十八届三中全会报告学习材料
2014/02/17 职场文书
家教广告词
2014/03/19 职场文书
根叔历年演讲稿
2014/05/20 职场文书
经营理念口号
2014/06/21 职场文书
校友会致辞
2015/07/30 职场文书
正确使用MySQL update语句
2021/05/26 MySQL
缓存替换策略及应用(以Redis、InnoDB为例)
2021/07/25 Redis
SpringBoot整合minio快速入门教程(代码示例)
2022/04/03 Java/Android