Detect broken Pillow (close #135)

This commit is contained in:
Paweł Jastrzębski committed 2015-05-07 22:37:48 +02:00
1 parent 9d190c1585
commit 36985f5169
1 file changed
+4 -1
+4 -1
View File
@@ -898,8 +898,11 @@ def detectCorruption(tmpPath, orgPath):
img.verify()
img = Image.open(path)
img.load()
except Exception:
except Exception as err:
rmtree(os.path.join(tmpPath, '..', '..'), True)
if 'decoder' in err and 'not available' in err:
raise RuntimeError('Pillow was compiled without JPG and/or PNG decoder.')
else:
raise RuntimeError('Image file %s is corrupted.' % pathOrg)
else:
os.remove(os.path.join(root, name))