python 图片 变清晰_python实现图片变亮或者变暗的方法
python實(shí)現(xiàn)圖片變亮或者變暗的方法
這篇文章主要介紹了python實(shí)現(xiàn)圖片變亮或者變暗的方法,涉及Python中Image模塊操作圖片的相關(guān)技巧,分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
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")
運(yùn)行效果如下所示:
希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。
完 謝謝觀(guān)看
總結(jié)
以上是生活随笔為你收集整理的python 图片 变清晰_python实现图片变亮或者变暗的方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 爬取百度迁徙2021年春运迁徙数据(仅省
- 下一篇: Python和Excel的完美结合:常用