[reportlab-users] What's wrong with this ?

Ian Sparks reportlab-users@reportlab.com
Mon, 23 Feb 2004 13:01:45 -0500

What ReportLab version are you using?

I'd update ReportLab to the latest version, my version here doesn't have =
a line :

rawdata =3D image.getRGBData()

instead it has :

rawdata =3D image.convert('RGB').tostring()

Update ReportLab then try again.

-----Original Message-----
From: philippe shrom [mailto:shrom@admin.zzn.com]
Sent: Monday, February 23, 2004 11:51 AM
To: reportlab-users@reportlab.com
Subject: [reportlab-users] What's wrong with this ?

Hi everebody,

I'm trying to include an image in a canva with drawImage like it is
specified in docs: "The image parameter may be either a
PIL Image object or an image filename."

here is the code:
 from reportlab.pdfgen import canvas
import Image

c =3D canvas.Canvas( "imagetest.pdf" )
img =3D Image.open('pict/logo.png')
c.drawImage(img, 150, 150 )

Here is the error:
Traceback (most recent call last):
  File "drawlogo.py", line 10, in ?
    c.drawImage(img, 150, 150 )

vas.py", line 586, in drawImage
    rawdata =3D image.getRGBData()
AttributeError: PngImageFile instance has no attribute 'getRGBData'

I looked at the source code of canvas.py and it is said:
"Draws the image (ImageReader object or filename) as specified"

Do I have to provide an ImageReader object or a PIL image object ?

Python 2.3.2
PIL 1.1.4
Windows 2000

Get your Free E-mail at http://admin.zzn.com
Get your own Web-based E-mail Service at http://www.zzn.com
reportlab-users mailing list