[reportlab-users] Failing to import a JPEG

Andy Robinson andy at reportlab.com
Wed May 18 11:20:55 EDT 2016


Hi Dinu,

(Adopting the lazy/busy approach of asking a question back to buy
time, while I google miniconda....)

Does the same code with the same jpeg file work OK in a plain,
pip-install-reportlab Python environment?

- Andy


On 18 May 2016 at 15:17, Dinu Gherman <gherman at darwin.in-berlin.de> wrote:
> 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
> reportlab-users at lists2.reportlab.com
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users


More information about the reportlab-users mailing list