Python PIL | blend() method
Last Updated :
15 Sep, 2022
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. PIL.Image.blend() method creates a new image by interpolating between two input images, using a constant alpha.
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:
Python3
from PIL import Image
im1 = Image. open (r"C:\Users\sadow984\Desktop\i2.PNG").convert( 'L' )
im2 = Image. open (r"C:\Users\sadow984\Desktop\c2.PNG").convert( 'L' )
im3 = Image.blend(im1, im2, 0.0 )
im3.show()
|
Output:
Python3
from PIL import Image
im1 = Image. open (r"C:\Users\sadow984\Desktop\i2.PNG").convert( 'L' )
im2 = Image. open (r"C:\Users\sadow984\Desktop\c2.PNG").convert( 'L' )
im3 = Image.blend(im1, im2, 1.0 )
im3.show()
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...