[reportlab-users] png mode "I" image inserted using drawImage but "blank" in resulting pdf

Robin Becker robin at reportlab.com
Wed Feb 16 11:04:32 EST 2011


On 16/02/2011 15:50, hari jayaram wrote:

> Hi I am trying to insert a PNG image with the following attributes

>

>>>> import Image

>>>> im = Image.open("harijay_test_mode_I.png")

>>>> im

> <PngImagePlugin.PngImageFile image mode=I size=800x600 at 0x1DEAFC8>

>

>

> The test code I am using to insert is given below.

> My problem is that although the code runs fine when the pdf is generated ,

> I get a white box where the image was supposed to be and my test grid

> numbers everywhere else.

>

> If I use another png in the rgba mode the image shows up and is correctly

> placed in the document.

>

> How do I insert PNG mode "F" or mode "I" images into reportlab documents.

> Alternatively how can I convert 16-bit depth images in PNG mode "I" or "F"

> to some mode that will insert into reportlab using python. I realize part of

> this question is more a PIL or pypng question , but I am hoping that there

> is a reportlab centric solution to my problem


well if PIL can do the conversion to RGB then you can pass the PIL image into
the reportlab.lib.utils ImageReader constructor to drawImage. PDF supports jpeg
natively and we try to preserve that, but beyond that we're just doing rgb (rgba
with some image types).


>

> Also I am using ubuntu Lucids built in PDF viewer to look at the resulting

> pdf and reportlab version 2.4

>

> Thanks

> Hari

.......

--
Robin Becker


More information about the reportlab-users mailing list