From 6d971a52459dbd0f437ef7f97bd0eef0e368759a Mon Sep 17 00:00:00 2001 From: josch Date: Mon, 21 Oct 2013 16:19:47 +0200 Subject: [PATCH] don't forget to seek and print better error --- img2pdf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/img2pdf.py b/img2pdf.py index bb1f9f1..0601288 100755 --- a/img2pdf.py +++ b/img2pdf.py @@ -97,12 +97,14 @@ def main(images, dpi, title=None, author=None, creator=None, producer=None, for im in images: rawdata = im.read() + im.seek(0) try: imgdata = Image.open(im) - except IOError: + except IOError as e: # test if it is a jpeg2000 image if rawdata[:12] != "\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A": - print "cannot read input image" + print "cannot read input image (not jpeg2000)" + print "PIL: %s"%e exit(1) # image is jpeg2000 width, height, ics = parsejp2(rawdata)