From 36985f5169ef8c864de357b44e201521dcde57d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Thu, 7 May 2015 22:37:48 +0200 Subject: [PATCH] Detect broken Pillow (close #135) --- kcc/comic2ebook.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index ce2e175..fa6c49f 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -898,9 +898,12 @@ def detectCorruption(tmpPath, orgPath): img.verify() img = Image.open(path) img.load() - except Exception: + except Exception as err: rmtree(os.path.join(tmpPath, '..', '..'), True) - raise RuntimeError('Image file %s is corrupted.' % pathOrg) + 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))