[reportlab-users] drawImage does not work with file pointer
John Keubler
jtkeubler at yahoo.com
Thu Feb 2 02:56:14 EST 2006
The following code does not work using a file pointer. It does work if the file name is
hardcoded directly into the drawImage function. I need to use a file pointer because
I am going to use the urlopen function to get images from a website. I don't want to
save the pictures to my hard drive, I would rather use a memory stream object. I
have tryed wraping the file pointer in a stringio function but this does not work either.
The image is a jpeg file.
Here is the code along with the error message:
# this does not work
f = file("c:/tmpf.img", "rb")
a = c.drawImage(f, 3*inch, 3*inch, width=1*inch, height=1*inch, mask=None)
print a
# this does work
f = file("c:/tmpf.img", "rb")
a = c.drawImage("c:/tmpf.img", 3*inch, 3*inch, width=1*inch, height=1*inch, mask=None)
print a
#error message
Traceback (most recent call last):
File "C:/Python24/pdftest4.py", line 37, in -toplevel-
a = c.drawImage(f, 3*inch, 3*inch, width=1*inch, height=1*inch, mask=None)
File "C:\Python24\Lib\site-packages\reportlab\pdfgen\canvas.py", line 570, in drawImage
rawdata = image.getRGBData()
AttributeError: 'file' object has no attribute 'getRGBData'
>>>
---------------------------------
Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new and used cars.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://two.pairlist.net/pipermail/reportlab-users/attachments/20060201/a791987a/attachment.html
More information about the reportlab-users
mailing list