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

python实现图片变亮或者变暗的方法,第1张

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

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

import Image# open an image file (.jpg or.png) you have in the working folderim1 = 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 functionim2 = 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 typeim2.show()# save modifIEd image to working folder as Audi2.jpgim2.save("angelababy2.jpg")

运行效果如下所示:

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

总结

以上是内存溢出为你收集整理的python实现图片变亮或者变暗的方法全部内容,希望文章能够帮你解决python实现图片变亮或者变暗的方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1202737.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-04
下一篇2022-06-04

发表评论

登录后才能评论

评论列表(0条)

    保存