Python PIL | ImageChops.darker() method

PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities.

ImageChops.darker() method is used to compare two images pixel by pixel, and returns a new image containing the 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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing Image class from PIL package
from PIL import ImageChops, Image
  
# opening images to compare
im1 = Image.open(r"C:\Users\Admin\Pictures\download.png")
im2 = Image.open(r"C:\Users\Admin\Pictures\images.png")
  
# Checking and returning a copy
# of image contating darker pixels
im = ImageChops.darker(im1, im2)
  
# showing image
im.show()

chevron_right


Output:

Code #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing Image class from PIL package
from PIL import ImageChops, Image
  
# opening images to compare
im1 = Image.open(r"C:\Users\Admin\Pictures\geeks.png")
im2 = Image.open(r"C:\Users\Admin\Pictures\capture.png")
  
# Checking and returning a copy
# of image contating darker pixels
im = ImageChops.darker(im1, im2)
  
# showing image
im.show()

chevron_right


Output:

Note: Don’t get confused with Image.blend() method. This method is totally different



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.