I have two png images with transparent background
example:
and I'm trying to achieve something similar to the PIL paste()
function in pyvips, where I can merge two images and 'remove the transparent background' using a mask.
PIL example:
image = Image.open(filepath, 'r')
image_2 = Image.open(filepath, 'r')
image.paste(image_2, (50, 50), mask=mask)
Expected Result:
I've already tried to use the pyvips insert()
function, but both images retain their backgrounds.
Pyvips insert:
image = pyvips.Image.new_from_file(path, access='sequential')
image_2 = pyvips.Image.new_from_file(path, access='sequential')
image = image.insert(image_2, 50,50)
Pyvips Result:
How can I have the "expected result" with pyvips?
You can do it like this, using the
composite()
function:If you want to add an offset in x and y, use: