Transparency in PNGs with reportlab 2.3

Dire Fungasaur picture Dire Fungasaur · Aug 20, 2009 · Viewed 9.5k times · Source

I have two PNGs that I am trying to combine into a PDF using ReportLab 2.3 on Python 2.5. When I use canvas.drawImage(ImageReader) to write either PNG onto the canvas and save, the transparency comes out black. If I use PIL (1.1.6) to generate a new Image, then paste() either PNG onto the PIL Image, it composits just fine. I've double checked in Gimp and both images have working alpha channels and are being saved correctly. I'm not receiving an error and there doesn't seem to be anything my google-fu can turn up.

Has anybody out there composited a transparent PNG onto a ReportLab canvas, with the transparency working properly? Thanks!

Answer

tsidwick picture tsidwick · Oct 26, 2009

Passing the mask parameter with a value of 'auto' to drawImage fixes this for me.

drawImage(......., mask='auto')

More information on the drawImage-function