[reportlab-users] drawImage and PIL

Kevin D Smith Kevin.Smith at sixquickrun.com
Thu Dec 3 14:23:37 EST 2009

What are the requirements for using PIL images with drawImage? I haven't been able to get it to work at all. I always get the following traceback:

File "test.py", line 502, in drawBackgroundImage
c.drawImage(im, x, y)
File "/Users/kesmit/pp/printtag/reportlab/pdfgen/canvas.py", line 817, in drawImage
imgObj = pdfdoc.PDFImageXObject(name, image, mask=mask)
File "/Users/kesmit/pp/printtag/reportlab/pdfbase/pdfdoc.py", line 2076, in __init__
ext = string.lower(os.path.splitext(source)[1])
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/posixpath.py", line 92, in splitext
i = p.rfind('.')
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PIL/Image.py", line 493, in __getattr__
raise AttributeError(name)
AttributeError: rfind

It looks like it can't detect that it is a PIL image, but I'm not sure why. I've tried it with just a basic jpeg and png, but they both have this same issue.

Kevin D Smith
Kevin.Smith at sixquickrun.com

More information about the reportlab-users mailing list