python实现图片变亮或者变暗的方法
更新时间:2015年06月01日 11:35:59 作者:皮蛋
这篇文章主要介绍了python实现图片变亮或者变暗的方法,涉及Python中Image模块操作图片的相关技巧,需要的朋友可以参考下
本文实例讲述了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程序设计有所帮助。
相关文章
wtfPython—Python中一组有趣微妙的代码【收藏】
Wtfpython讲解了大量的Python编译器的内容。这篇文章主要介绍了wtfPython-Python中一些奇妙的代码,感兴趣的朋友跟随脚本之家小编一起看看吧2018-08-08scrapy框架携带cookie访问淘宝购物车功能的实现代码
这篇文章主要介绍了scrapy框架携带cookie访问淘宝购物车,本文通过实例代码图文详解给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2020-07-07python人工智能tensorflow常用激活函数Activation Functions
这篇文章主要为大家介绍了python人工智能tensorflow常用激活函数Activation Functions的汇总介绍,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2022-05-05Python 使用ConfigParser操作ini配置文件
这篇文章主要介绍了Python 使用ConfigParser操作ini配置文件的相关资料,需要的朋友可以参考下2023-05-05
最新评论