[Python] python PIL - check if image is transparent

Discussão em 'Python' iniciado por Stack, Agosto 18, 2025.

  1. Stack

    Stack Membro Participativo

    I am pasting an image on another image, and after looking at this question, I saw that in order to paste a transparent image, you need to do

    background = Image.open("test1.png")
    foreground = Image.open("test2.png")

    background.paste(foreground, (0, 0), foreground)


    with a normal image, you should do

    background = Image.open("test1.png")
    foreground = Image.open("test2.png")

    background.paste(foreground, (0, 0)) // difference here


    my question is, how can I check if an image it transparent so I can determine how to use the paste method (with or without the last parameter).

    Continue reading...

Compartilhe esta Página