[reportlab-users] bug with image transparency?!

Robin Becker robin at reportlab.com
Tue Oct 21 05:29:06 EDT 2008


Tim Roberts wrote:

> Volker Haas wrote:

>> I guess I just ran into an image which is not rendered correctly using

>> reportlab (version 2.1).

>> All black pixels are rendered white (or transparent on a white

>> background).

>> The image displays correctly in a browser or image viewer.

>> ...

>> from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame,

>> Image

>> from reportlab.rl_config import defaultPageSize

>>

>> doc = BaseDocTemplate("test.pdf")

>>

>> frame = Frame(0,0,defaultPageSize[0], defaultPageSize[1])

>> doc.addPageTemplates(PageTemplate(frames=frame))

>>

>> Story = [Image("MergeSampleStep1.png")]

>> doc.build(Story)

>

> Very interesting; I think there is some confusion in the code between

> Platypus and canvas about what the "mask" parameter means. In the short

> term, you can work around this by saying:

>

> Story = [Image("MergeSampleStep1.png", mask=None)]

>

> At least, that fixed your sample for me.

>

At present we're not dealing with mode 'P' correctly. We're able to deal with
RGBA CMYK L and RGB. Currently stuff that is in mode P will be converted to RGB.
My reading of the PIL manual suggests that mode P is a palette format with the
actual colour space any of the others. It seems that conversions to L RGB and
CMYK are supported without loss and that the way to convert is to omit the
outcome mode argument. I assume that we would then need to carry the transparent
colour along as a singleton as in with a mask colour. Can you send me a small
sample image?
--
Robin Becker


More information about the reportlab-users mailing list