pythonpython-imaging-library

Lower the brightness of an Image using Pillow


I'm using Pillow for a project, and I really want to create an effect like in the following Image, look:

To Throw a chicken at oneself

In this picture, you see like the background Image is opaque, I don't know if that's the word I need to use. What I want to do is that the text is brighter than the background Image, this is a nice effect.

Can I duplicate this effect in Pillow? and if so, what would be the function? Thank you a lot. I know this is a broad question, but since I don't know how to even ask the question the proper way, I will accept any suggestion that will lead me to the right path.

PS. I found this picture at: http://qz.com/402739/the-best-idioms-from-around-the-world-ranked/


Solution

  • Based on the comment of @martineau

    from PIL import Image
    
    im = Image.open('image-to-modify.jpg')
    
    source = im.split()
    
    R, G, B = 0, 1, 2
    constant = 1.5 # constant by which each pixel is divided
    
    Red = source[R].point(lambda i: i/constant)
    Green = source[G].point(lambda i: i/constant)
    Blue = source[B].point(lambda i: i/constant)
    
    im = Image.merge(im.mode, (Red, Green, Blue))
    
    im.save('modified-image.jpeg', 'JPEG', quality=100)