I'm using Pillow for a project, and I really want to create an effect like in the following Image, look:
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/
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)
As stated in the docs you can use Pillow's ImageEnhance
module for lowering or increasing the brightness of an image.
Minimal Working Example (MWE):
from PIL import Image, ImageEnhance
img = Image.open("image.jpg")
enhancer = ImageEnhance.Brightness(img)
# to reduce brightness by 50%, use factor 0.5
img = enhancer.enhance(0.5)
img.show()
img.save("image_darker.jpg")
So to get the text of the image brighter than the background image, first apply the effect to the image, then add the text.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.