[reportlab-users] PIL frombuffer question
Paul Guse
paul at mustagh.com
Thu Mar 8 13:14:09 EST 2007
Hello. I'm trying to write raw pixel data to a pdf using reportlab.
I've attempted to do this by creating a PIL image using frombuffer, create an ImageReader object from that PIL image, then draw this on the canvas. Here's my test code:
data = ''.join([chr(x%255) for x in range(30000)])
im = PIL.Image.frombuffer ('RGB', (100,100), data, "raw", 'RGB', 0, 1)
ir = ImageReader (im)
c = Canvas("test.pdf", pagesize=letter)
c.drawImage (ir, 100, 100, 100, 100)
c.showPage ()
c.save ()
However, I get the following error:
Traceback (most recent call last):
File "imagetest.py", line 3, in ?
ir = ImageReader (im)
File "reportlab\lib\utils.py", line 518, in __init__
File "C:\Python24\Lib\site-packages\PIL\Image.py", line 493, in __getattr__
raise AttributeError(name)
AttributeError: fp
So there seems to be problem with there not being a file? Any thoughts on what I'm doing wrong? Or a better way to accomplish this?
Thanks.
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://two.pairlist.net/pipermail/reportlab-users/attachments/20070308/b039e2ee/attachment.htm
More information about the reportlab-users
mailing list