From cc0eddd3db68793d2dcaae0e7a9e02f29e4b8645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gab=C3=A8s=20Jean?= Date: Thu, 29 Oct 2015 21:00:51 +0100 Subject: [PATCH] Fix: catch a bug with bogus images and crop feature A new exception was raised by the PIL lib in the crop part, so was not catch by the previous catch feature. --- mangle/image.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mangle/image.py b/mangle/image.py index 421bec3..dcd6563 100644 --- a/mangle/image.py +++ b/mangle/image.py @@ -183,7 +183,10 @@ def orientImage(image, size): # by inverting colors, and asking a bounder box ^^ @protect_bad_image def autoCropImage(image): - x0, y0, xend, yend = ImageChops.invert(image).getbbox() + try: + x0, y0, xend, yend = ImageChops.invert(image).getbbox() + except TypeError: # bad image, specific to chops + return image image = image.crop((x0, y0, xend, yend)) return image