[reportlab-users] Failing to import a JPEG
Dinu Gherman
gherman at darwin.in-berlin.de
Wed May 18 10:17:57 EDT 2016
Hi,
after a two year break I’m trying to create a PDF using reportlab again, and fail at inserting a simple JPEG bitmap. I’m using Miniconda 2.7.11, and reportlab==3.3.0, Pillow==3.2.0 as reported by pip freeze, and this really simple code below gives me a traceback, that I’d like to see disappear until tomorrow… Any ideas?
Thanks,
Dinu
from reportlab.lib.pagesizes import A4
from reportlab.pdfgen.canvas import Canvas
from PIL import Image
path = "test.pdf"
canv = Canvas(path, pagesize=A4)
image = Image.open('logos/foo.jpg')
canv.drawImage(image, 0, 0)
canv.save()
$ ~/miniconda2/bin/python test.py
Traceback (most recent call last):
File "test.py", line 11, in <module>
canv.drawImage(image, 0, 0)
File "/Users/dinu/miniconda2/lib/python2.7/site-packages/reportlab/pdfgen/canvas.py", line 946, in drawImage
imgObj = pdfdoc.PDFImageXObject(name, image, mask=mask)
File "/Users/dinu/miniconda2/lib/python2.7/site-packages/reportlab/pdfbase/pdfdoc.py", line 2098, in __init__
ext = os.path.splitext(source)[1].lower()
File "/Users/dinu/miniconda2/lib/python2.7/posixpath.py", line 98, in splitext
return genericpath._splitext(p, sep, altsep, extsep)
File "/Users/dinu/miniconda2/lib/python2.7/genericpath.py", line 99, in _splitext
sepIndex = p.rfind(sep)
File "/Users/dinu/miniconda2/lib/python2.7/site-packages/PIL/Image.py", line 632, in __getattr__
raise AttributeError(name)
AttributeError: find
More information about the reportlab-users
mailing list