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

hari jayaram harijay at gmail.com
Wed Feb 16 10:50:14 EST 2011

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

Also I am using ubuntu Lucids built in PDF viewer to look at the resulting
pdf and reportlab version 2.4


###########Test code#########

import reportlab
from reportlab.pdfgen import canvas
from reportlab.lib import pagesizes
from reportlab.lib.pagesizes import letter
from reportlab.lib.units import inch,mm

c = canvas.Canvas("hellotc.pdf",pagesize=pagesizes.landscape(letter))

for x in range(0,11,1):
# setup a guidance grid for image placement initially
for y in range(0,9,1):
c.drawString(x*inch,y*inch,"%d,%d" % (x,y))

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20110216/2f01a8a5/attachment.html>

More information about the reportlab-users mailing list