Transparent PNG in PIL turns out not to be transparent

I think what you want to use is the paste mask argument.
see the docs, (scroll down to paste)

from PIL import Image
img = Image.open(basefile)
layer = Image.open(layerfile) # this file is the transparent one
print layer.mode # RGBA
img.paste(layer, (xoff, yoff), mask=layer) 
# the transparancy layer will be used as the mask
img.save(outfile)

Leave a Comment