有人说: "要么旅行,要么读书,身体和灵魂,必须有一个在路上。 "这次川西之行我们走进四姑娘山。四姑娘山,是四座并立的山峰,山体陡峭,直指蓝天,冰雪覆盖,银光照人,享有 "蜀山皇后 "的美誉。
本文实例讲述了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实现图片变亮或者变暗的方法请关注haodaima.com其它相关文章!