I want to subtract one image from the other using the first one’s alpha channel.
The problem is really hard for me to explain by words, so please bear with me and my art.
Imagine that I have the following image. Let’s call it image “A”:
Image A
I also have another one, image “B”:
Image B
B is an image of a terrifyingly complex shape. It also has some transparency, as depicted by the checkered background.
Now, imagine that after I place B on top of A, I get the following:
B on top of A
Here’s the problem; I want to get the following output:
Expected Output
What’s happening here is that after placing B on top of A, I want to preserve the area form image A where it intersects with image B’s INNER transparent area, but remove parts of A where it intersects with B’s OUTER transparent area. Also, B’s RGB must be preserved.
How can I achieve this in python?
Sand dan Glokta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.