Python Pillow: Convert Color Image to Grayscale Image

In this tutorial, we will use an example to convert a color image to grayscale using python pillow.

Python Pillow - Convert Color Image to Grayscale Image - A Step Guide

1.Open a color image

from PIL import Image
img = Image.open('test.jpg')

2.Convert to grayscale image

gray_img = img.convert('L')

3.Display grayscale image

gray_img.show()

If you plan to save grayscale image, you can use

gray_img.save('t.jpg')

Python Pillow - Convert Color Image to Grayscale Image