Friday, October 3, 2025
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

Most Popular

Dominic
32332 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11868 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11929 POSTS0 COMMENTS
Shaida Kate Naidoo
6818 POSTS0 COMMENTS
Ted Musemwa
7080 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS