Re: Failing to import a JPEG

Andy Robinson <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <CABjtAptyUA0Xn7Ngaq0_yXC7tt46tkkcmUJk6eQa_xDmNgAyLQ@mail.gmail.com>
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 <[email protected]> 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
> [email protected]
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users
_______________________________________________
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.