2948 explained code solutions for 75 technologies


python-pillowHow to convert an image to grayscale


from PIL import Image, ImageFilter

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

im.show()ctrl + c
PIL

import Pillow package modules

Image.open

open given image with Pillow

convert('L')

convert image to gray scale colors

.show()

displays resulting image