Wednesday, January 21, 2026
HomeLanguagesPython PIL | ImageOps.grayscale() method

Python PIL | ImageOps.grayscale() method

PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The ImageOps module contains a number of ‘ready-made’ image processing operations. This module is somewhat experimental, and most operators only work on L and RGB images.
ImageOps.grayscale() Convert the image to grayscale. The complete pixel turns to gray, no other color will be seen.
 

Syntax: PIL.ImageOps.grayscale(image) 
Parameters
image – The image to convert into grayscale.
Returns An image. 
 

Image Used: 
 

 

Python3




# Importing Image and ImageOps module from PIL package
from PIL import Image, ImageOps
     
# creating a image1 object
im1 = Image.open(r"C:\Users\System-Pc\Desktop\a.JPG")
 
# applying grayscale method
im2 = ImageOps.grayscale(im1)
 
im2.show()


Output:
 

 

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7220 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS