Python PIL | blend() method
Syntax: PIL.Image.blend(image1, image2, alpha).
Parameter:
image1: first image
image2: second image, must have the same mode and size as the first image.
alpha: The interpolation alpha factor. If alpha is 0.0, a copy of the first image is returned. If alpha is 1.0, a copy of the second image is returned. There are no restrictions on the alpha value. If necessary, the result is clipped to fit into the allowed output range.
Image1:

Image2:

# Importing Image module from PIL package from PIL import Image # creating a image1 object and convert it to mode 'P' im1 = Image.open(r"C:\Users\sadow984\Desktop\i2.PNG").convert('L') # creating a image2 object and convert it to mode 'P' im2 = Image.open(r"C:\Users\sadow984\Desktop\c2.PNG").convert('L') # alpha is 0.0, a copy of the first image is returned im3 = Image.blend(im1, im2, 0.0) # to show specified image im3.show() |
Output:

# Importing Image module from PIL package from PIL import Image # creating a image1 object and convert it to mode 'P' im1 = Image.open(r"C:\Users\sadow984\Desktop\i2.PNG").convert('L') # creating a image2 object and convert it to mode 'P' im2 = Image.open(r"C:\Users\sadow984\Desktop\c2.PNG").convert('L') # alpha is 1.0, a copy of the second image is returned im3 = Image.blend(im1, im2, 0.0) # to show specified image im3.show() |
Output:
Recommended Posts:
- class method vs static method in Python
- Python | os.dup() method
- Python | set() method
- Python | next() method
- Python | sympy.apart() method
- Python PIL | getbands() method
- Python | os.strerror() method
- Python | os.getcwd() method
- Python | os.ftruncate() method
- Python | os.truncate() method
- Python | os.major() method
- Python | os.sched_getaffinity() method
- Python | Method Overloading
- Python | shutil.which() method
- Python | os.minor() method
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.



