Spaces:
Building
on
Zero
Building
on
Zero
File size: 237 Bytes
d1ae10f |
1 2 3 4 5 6 7 8 9 |
from PIL import Image
def flatten(img, bgcolor):
# Replace transparency with bgcolor
if img.mode in ("RGB"):
return img
return Image.alpha_composite(Image.new("RGBA", img.size, bgcolor), img).convert("RGB")
|