Transparent PNG in PIL turns out not to be transparent

后端 未结 1 962
感情败类
感情败类 2020-12-24 06:53

I have been hitting my head against the wall for a while with this, so maybe someone out there can help.

I\'m using PIL to open a PNG with transparent background and

相关标签:
1条回答
  • 2020-12-24 07:35

    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)
    
    0 讨论(0)
提交回复
热议问题