Closed seanyo closed 11 years ago
Due to the way that ReportLab handles image transparency this looks like it will be a real pain. Too bad, since PNG has such good built-in alpha transparency support...
I found this on Stack Overflow; perhaps it will help:
Question
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
passing the mask parameter with a value of 'auto' to drawImage fixes this for me.
drawImage(......., mask='auto')
Source: http://stackoverflow.com/questions/1308710/transparency-in-pngs-with-reportlab-2-3
Thanks, Sean.
Unfortunately this doesn't seem to work.
Rather, it does seem to work with some profile pictures (e.g. http://twitter.com/#!/seydoggy) but not others (e.g. http://twitter.com/#!/ginader).
Hello,
drawImage(......., mask='auto') works perfectly.
System: ubuntu 12 , python 2.7
@tejastank Thanks! I was going to ask if you tested with the images listed by @ccharles, but it appears that Twitter no longer supports transparent PNGs.
https://twitter.com/thomasfuchs/status/252151280842186753
That being said - I'd prefer to resolve the issue in case they come back or in case the code gets extended to pull content from a Twitter Compatible API or another source of user profiles.
What do you think @ccharles
I would love to see the official announcement of this new Twitter "feature". The wording would be interesting…
Since we cannot test against the images that used to fail I'm inclined to close this issue as no longer valid. We can always reopen if and when it comes up again.
Alpha transparencies are rendered as black:
Example ID: http://twitter.com/#!/ginader