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 中文乱码问题深入分析
Mar 13 Python
Python实现高效求解素数代码实例
Jun 30 Python
python 自动化将markdown文件转成html文件的方法
Sep 23 Python
python:socket传输大文件示例
Jan 18 Python
基于python的Tkinter编写登陆注册界面
Jun 30 Python
对python中的logger模块全面讲解
Apr 28 Python
python散点图实例之随机漫步
Aug 27 Python
python里 super类的工作原理详解
Jun 19 Python
python构建指数平滑预测模型示例
Nov 21 Python
opencv3/C++实现视频背景去除建模(BSM)
Dec 11 Python
python实现打砖块游戏
Feb 25 Python
python录音并调用百度语音识别接口的示例
Dec 01 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多个版本的分析解释
2011/07/21 PHP
phpmyadmin安装时提示:Warning: require_once(./libraries/common.inc.php)错误解决办法
2011/08/18 PHP
destoon实现商铺管理主页设置增加新菜单的方法
2014/06/26 PHP
浅谈php冒泡排序
2014/12/30 PHP
php批量删除操作(数据访问)
2017/05/23 PHP
javascript suggest效果 自动完成实现代码分享
2012/02/17 Javascript
博客侧边栏模块跟随滚动条滑动固定效果的实现方法(js+jquery等)
2013/03/24 Javascript
js实现页面转发功能示例代码
2013/08/05 Javascript
JavaScript网页定位详解
2014/01/13 Javascript
tuzhu_req.js 实现仿百度图片首页效果
2015/08/11 Javascript
网页从弹窗页面单选框传值至父页面代码分享
2015/09/29 Javascript
Bootstrap基本组件学习笔记之面板(14)
2016/12/08 Javascript
React.js中常用的ES6写法总结(推荐)
2017/05/09 Javascript
详解webpack + vue + node 打造单页面(入门篇)
2017/09/23 Javascript
认识jQuery的Promise的具体使用方法
2017/10/10 jQuery
jQuery基于cookie实现换肤功能实例
2017/10/14 jQuery
原生JS实现的轮播图功能详解
2018/08/06 Javascript
JS实现网站吸顶条
2020/01/08 Javascript
vue中v-for循环选中点击的元素并对该元素添加样式操作
2020/07/17 Javascript
[30:37]【全国守擂赛】第三周擂主赛 Dark Knight vs. Leopard Gaming
2020/05/04 DOTA
5款非常棒的Python工具
2018/01/05 Python
Python简单实现网页内容抓取功能示例
2018/06/07 Python
使用Python编写Prometheus监控的方法
2018/10/15 Python
Python如何实现强制数据类型转换
2019/11/22 Python
对tensorflow中tf.nn.conv1d和layers.conv1d的区别详解
2020/02/11 Python
opencv 图像礼帽和图像黑帽的实现
2020/07/07 Python
编译 pycaffe时报错:fatal error: numpy/arrayobject.h没有那个文件或目录
2020/11/29 Python
PyQt5中QSpinBox计数器的实现
2021/01/18 Python
美国电视购物HSN官网:HSN
2016/09/07 全球购物
Schutz鞋官方网站:Schutz Shoes
2017/12/13 全球购物
公司市场部岗位职责
2013/12/02 职场文书
2014年廉洁自律承诺书
2014/05/26 职场文书
地理信息科学专业推荐信
2014/09/08 职场文书
村党支部书记个人对照材料汇报
2014/10/26 职场文书
2014年城管个人工作总结
2014/12/08 职场文书
村主任当选感言
2015/08/01 职场文书