summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2013-05-27 11:59:33 +0200
committerHelmut Grohne <helmut@subdivi.de>2013-05-27 11:59:33 +0200
commit3667c29f675599b9f3e098dd9b708c1d099d2b8a (patch)
treefcf001b6ccf0fa13ab8c9277666f1e65b02d4a35
parent8c73deb776877cd7bc3739577ee24f9cc07a3337 (diff)
downloaddebian-dedup-3667c29f675599b9f3e098dd9b708c1d099d2b8a.tar.gz
dedup.image: img.convert can also raise that crazy stuff
-rw-r--r--dedup/image.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/dedup/image.py b/dedup/image.py
index acbf0ca..1148890 100644
--- a/dedup/image.py
+++ b/dedup/image.py
@@ -62,7 +62,10 @@ class ImageHash(object):
elif img.mode == "RGB":
pack = lambda elem: struct.pack("BBBB", *(elem + (255,)))
elif img.mode != "RGBA":
- img = img.convert("RGBA")
+ try:
+ img = img.convert("RGBA")
+ except (SyntaxError, IndexError, IOError): # crazy stuff from PIL
+ raise ValueError("error reading png image")
try:
for elem in img.getdata():
hashobj.update(pack(elem))