Python PIL | ImageChops.darker () method

Python Methods and Functions

ImageChops.darker () is used to compare two images pixel by pixel and returns a new image containing darker values.

Syntax: ImageChops.darker (image1, image2)

Parameters:
image1: It is the image object or image path of first image.
image2: It is the image object or image path of second image.

Return Value: An Image

Note: Both images should be of same MODE.

Code # 1:

# import image class from PIL

from PIL import ImageChops, Image

  
# open images for comparison

im1 = Image. open (r "C : UsersAdminPicturesdownload.png " )

im2 = Image. open (r "C: UsersAdminPicturesimages.png" )

 
# Check and return a copy
Number of images containing darker pixels

im = ImageChops.darker (im1, im2)

 
# show image
im.show ()

Output:

Code # 2:

# import image class from PIL

from PIL import ImageChops, Image

 
# open images for comparison

im1 = Image. open (r "C: UsersAdminPicturesgeeks.png" )

im2 = < / code> Image. open (r " C: UsersAdminPicturescapture.png " )

  
# Check and return a copy
Number of images containing darker pixels

im = ImageChops.darker (im1, im2)

 
# show the image
im.show ()

Output:

Note: Not to be confused with Image.blend () method. This method is completely different





Tutorials