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

philippe shrom reportlab-users@reportlab.com
Mon, 23 Feb 2004 17:51:28 +0100


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 = canvas.Canvas( "imagetest.pdf" )
img = Image.open('pict/logo.png')
c.drawImage(img, 150, 150 )
c.showPage()
c.save()

Here is the error:
Traceback (most recent call last):
  File "drawlogo.py", line 10, in ?
    c.drawImage(img, 150, 150 )
  File
"E:\programmation\python\python2.3\Lib\site-packages\reportlab\pdfgen\can
vas.py", line 586, in drawImage
    rawdata = 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