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).
解决方案
Check the mode of the image for an alpha transparency layer. For example, RGB has no transparency, but RGBA does.