I'm trying to paste an image onto a backgorund with Python Imaging Library like this:
card = Image.new("RGB", (220, 220), (255, 255, 255))
img = Image.open("/Users/paulvorobyev/test.png")
...
x, y = img.size
card.paste(img, (0, 0, x, y), img)
card.save("test.png")
When I run this code, I get:
"ValueError: bad transparency mask"
What did I do wrong?
Late to the game here, but I just ran into the same issue. After some googling I was able to get my mask to work by making sure all of the images being used were the same mode (specifically "RGBA").
You might try this:
card = Image.new("RGBA", (220, 220), (255, 255, 255)) img = Image.open("/Users/paulvorobyev/test.png").convert("RGBA") x, y = img.size card.paste(img, (0, 0, x, y), img) card.save("test.png", format="png")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With