Failing to import a JPEG

Dinu Gherman <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <[email protected]>
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


_______________________________________________
reportlab-users mailing list
[email protected]
https://pairlist2.pair.net/mailman/listinfo/reportlab-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.