zimeon / iiif

IIIF Image API reference implementation and Python library
GNU General Public License v3.0
55 stars 15 forks source link

Tidy error message when a PDF file is fed to iiif_static.py #16

Closed zimeon closed 7 years ago

zimeon commented 8 years ago

@jgreidy reports a rather unhelpful error message if one feeds a PDF file to iiif_static.py:

Traceback (most recent call last):
  File "/cul/share/iiif/iiif/iiif_static.py", line 82, in <module>
    main()
  File "/cul/share/iiif/iiif/iiif_static.py", line 73, in main
    sg.generate(source, identifier=opt.identifier)
  File "/cul/share/iiif/iiif/iiif/static.py", line 127, in generate
    im.do_first()
  File "/cul/share/iiif/iiif/iiif/manipulator_pil.py", line 45, in do_first
    raise IIIFError(text=("PIL Image.open(%s) barfed:
%s"%(self.srcfile,str(e))))
iiif.error.IIIFError: <?xml version='1.0' encoding='UTF-8'?>
<error xmlns="http://library.stanford.edu/iiif/image-api/ns/">
<parameter>unknown</parameter>
<text>PIL Image.open(/tmp/image-to-iiif-s3/test/seapapers/image.pdf)
barfed: cannot identify image file
'/tmp/image-to-iiif-s3/test/seapapers/image.pdf'</text>
</error>
Caught exception: Error Processing iiif: Command failed: python
/cul/share/iiif/iiif/iiif_static.py --api-version 2.0 -d
/tmp/image-to-iiif-s3/test/seapapers/iiif -p
XXX/image.pdf

There is no support for PDF but a better message would be nice.

zimeon commented 8 years ago

On current image_api_2.1 branch, output for a PDF is:

(py3)simeon@RottenApple iiif>./iiif_static.py --dst /tmp chamberlain.interiew.pdf 
iiif_static.py: source file: chamberlain.interiew.pdf
iiif_static.py: Error: PIL Image.open(chamberlain.interiew.pdf) barfed: cannot identify image file 'chamberlain.interiew.pdf', parameter=unknown, code=500
zimeon commented 7 years ago

Seems adequately fixed by merge of #17. Done.