So far, we have already seen how to blend two images together. It was done using the Image.blend
operation where the two input images were blended by using a constant alpha
transparency factor. In this section, we will learn another technique to combine two images together. Here, instead of a constant alpha
factor, an image instance that defines the transparency mask is used as the third argument. Another difference is that the input images need not have the same mode
. For instance, the first image can be with mode L
and the second with mode RGBA
. The syntax to create composite images is:
outImage = Image.composite(img1, img2, mask)
Here, the arguments to the composite method are Image
instances. The mask is specified as alpha
. The mode for mask image instance can be 1
, L
, or RGBA
.