views:

398

answers:

2

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!

A: 

ReportLab uses PIL for managing images. Currently, PIL trunk has patch applied to support transparent PNGs, but you will have to wait for a 1.1.6 release if you need stable package.

iElectric
+2  A: 

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

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

tsidwick
Worked for me too - thanks!
Orange Box