9951 explained code solutions for 126 technologies


python-pillowHow to increase image contrast


from PIL import Image, ImageEnhance

im = Image.open('/var/www/examples/heroine.png')

im = ImageEnhance.Contrast(im).enhance(1.5)
im.show()ctrl + c
PIL

import Pillow package modules

Image.open

open given image with Pillow

/var/www/examples/heroine.png

path to sample image to open

ImageEnhance.Contrast

object to manipulate image contrast

.enhance(

increases contrast to a given value

1.5

we'll increase contrast by 50%

.show()

displays resulting image