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.
This commit is contained in:
parent
a061ef26fe
commit
cc0eddd3db
@ -183,7 +183,10 @@ def orientImage(image, size):
|
|||||||
# by inverting colors, and asking a bounder box ^^
|
# by inverting colors, and asking a bounder box ^^
|
||||||
@protect_bad_image
|
@protect_bad_image
|
||||||
def autoCropImage(image):
|
def autoCropImage(image):
|
||||||
|
try:
|
||||||
x0, y0, xend, yend = ImageChops.invert(image).getbbox()
|
x0, y0, xend, yend = ImageChops.invert(image).getbbox()
|
||||||
|
except TypeError: # bad image, specific to chops
|
||||||
|
return image
|
||||||
image = image.crop((x0, y0, xend, yend))
|
image = image.crop((x0, y0, xend, yend))
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user