Thursday, September 4, 2025
HomeLanguagesPython PIL | ImageChops.constant()

Python PIL | ImageChops.constant()

PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.

PIL.ImageChops.constant()Fill a channel with a given grey level.

Syntax: PIL.ImageChops.constant(image, value)

Parameters:
image– take an image with there extension type.

Returns: An Image.

Image Used:




   
  
# importing image object from PIL
from PIL import Image, ImageChops  
  
# creating an image object 
img = Image.open(r"C:\Users\System-Pc\Desktop\TREE.JPG") 
img1 = ImageChops.constant(img, 60) 
    
img1.show() 


Output:

Another Example:Taking another image with different value to see the change in grey intensity.

Image Used:




   
  
# importing image object from PIL
from PIL import Image, ImageChops  
  
# creating an image object 
img = Image.open(r"C:\Users\System-Pc\Desktop\rose.jpg") 
img1 = ImageChops.constant(img, 200) 
    
img1.show() 


Output:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6632 POSTS0 COMMENTS
Nicole Veronica
11800 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11860 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS