flatcherlee's picture
Upload 2334 files
3d5837a verified
raw
history blame contribute delete
237 Bytes
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")