User Tools

Site Tools


pillow

Converting RGBA to RGB with Python 3 + PIL / Pillow

from PIL import Image
def rgba_to_rgb(image):
    image.load()
    backg = Image.new("RGB", png.size, (255, 255, 255))
    backg.paste(png, mask=png.split()[3]) # 3 is the alpha channel
    return backg
pillow.txt · Last modified: 2024/04/11 14:23 by 127.0.0.1