PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities.
PIL.Image.composite()
method creates composite image by blending images using a transparency mask. Here, mask is another image which remains transparent when composite together.
Syntax: PIL.Image.composite(image1, image2, mask)
Parameters:
image1 – The first image.
image2 – The second image. Must have the same mode and size as the first image.
mask – A mask image. This image can have mode “1”, “L”, or “RGBA”, and must have the same size as the other two images.
from PIL import Image
im1 = Image. open (r "C:\Users\sadow984\Desktop\c2.PNG" ).convert( 'L' )
im1.show()
|
Showing image1:

from PIL import Image
im2 = Image. open (r "C:\Users\sadow984\Desktop\i2.PNG" ).convert( 'L' )
im2.show()
|
Showing image2:

from PIL import Image
mask = Image. open (r "C:\Users\sadow984\Desktop\i3.PNG" ).convert( 'L' )
mask.show()
|
Showing mask image:

from PIL import Image
im1 = Image. open (r "C:\Users\sadow984\Desktop\c2.PNG" ).convert( 'L' )
im2 = Image. open (r "C:\Users\sadow984\Desktop\i2.PNG" ).convert( 'L' )
mask = Image. open (r "C:\Users\sadow984\Desktop\i3.PNG" ).convert( 'L' )
im3 = Image.composite(im1, im2, mask)
im3.show()
|
Output: [the composite image]

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
15 Nov, 2021
Like Article
Save Article