I'm using Pillow to cut out a shape from an image. To do this, I'm using an alpha mask that contains a black and white image of the shape I need. When I apply the mask with Pillow, I'm left with a cutout of the image, like I wanted, but it's outlined by a completely unrelated picture from a different folder.
The mask I'm using is this one:
When I combine it with a random picture from the interwebs (this one to be exact), I get this as a result:
The white border surrounding the image is located in a different folder from the working one and is never referenced by my code.
I've no earthly idea how Pillow is getting the white border. It's really quite frustrating. Anybody know why this happens?
For reference, here's the code as well:
from PIL import Image
def Blend_Pic():
background = Image.open("bg.png")
mask = Image.open("mask2.png").convert("L")
foreground = Image.open("fg.png")
background.paste(foreground, (0, 0), mask)
background.show()
if __name__ == "__main__":
Blend_Pic()
the background is just an empty 1600x900 png, and the foreground is the random image from google.
Edit: Changing the mask to be just a simple rectangle gave the same results, so changing the mask didn't help.