Python one sentence code lightens or darkens the image

From , 5 Years ago, written in Python, viewed 205 times.
URL https://pastebin.vip/view/8da57fac
  1. # do pixel math on an image using the PIL image library
  2. # free from:  http://www.pythonware.com/products/pil/index.htm
  3. # Python23 tested      vegaseat     22jan2005
  4. import Image
  5. # open an image file (.jpg or.png) you have in the working folder
  6. im1 = Image.open("Audi.jpg")
  7. # multiply each pixel by 0.9 (makes the image darker)
  8. # works best with .jpg and .png files, darker < 1.0 < lighter
  9. # (.bmp and .gif files give goofy results)
  10. # note that lambda is akin to a one-line function
  11. im2 = im1.point(lambda p: p * 0.9)
  12. # brings up the modified image in a viewer, simply saves the image as
  13. # a bitmap to a temporary file and calls viewer associated with .bmp
  14. # make certain you have associated an image viewer with this file type
  15. im2.show()
  16. # save modified image to working folder as Audi2.jpg
  17. im2.save("Audi2.jpg")
  18. #//python/5727

Reply to "Python one sentence code lightens or darkens the image"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website