don't forget to seek and print better error

This commit is contained in:
josch 2013-10-21 16:19:47 +02:00
parent 610a5ecdd6
commit 6d971a5245

View file

@ -97,12 +97,14 @@ def main(images, dpi, title=None, author=None, creator=None, producer=None,
for im in images: for im in images:
rawdata = im.read() rawdata = im.read()
im.seek(0)
try: try:
imgdata = Image.open(im) imgdata = Image.open(im)
except IOError: except IOError as e:
# test if it is a jpeg2000 image # test if it is a jpeg2000 image
if rawdata[:12] != "\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A": 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) exit(1)
# image is jpeg2000 # image is jpeg2000
width, height, ics = parsejp2(rawdata) width, height, ics = parsejp2(rawdata)