TECHIES WORLD

For Techs.... Techniques.... Technologies....

LinuxPython

How to convert an image to gray scale in Python

PIL is the Python image library. Its is a free library for the Python programming language that adds support for opening, manipulating, and saving many different image file formats. It is available for Windows, Mac OS X and Linux.

To convert an image to gray scale we can use the following format.

 
from PIL import Image

im = Image.open('image.jpg')
im = im.convert("L")

 
Here we need to replace image.jpg with the name of the image.

Leave a Reply