"/>
I think you're (understandably) being confused by what the img.show()
is displaying — which I believe is wrong (and may in fact be a bug). On my Windows system a temporary .BMP image is displayed, and it looks like the transparent pixels are black.
However if you add a line like img.save('arbol16_mod.png')
at the end and then view that image file by manually opening it in some image file viewing program, such as Paint, Windows Photo Viewer, or Photoshop, the result is correct.
The paste
method does not take into account the alpha of the image it's pasting; you need to add a mask
parameter to control that. If the image you're pasting is RGBA
you can just pass it twice.
arbol16 = arbol16.convert("RGBA")
img.paste(arbol16, (0, 0, 16, 16), arbol16)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.