check for read error

This commit is contained in:
Antonio J. Delgado 2021-10-10 15:10:30 +03:00
parent d22c20614e
commit 824787b860

View file

@ -178,6 +178,9 @@ class image_classifier:
def is_image(self, file):
try:
image_object = PIL.Image.open(file)
except OSError as error:
self._log.debug(f"File '{file}' is not readable by PIL. {error}")
return False
except PIL.UnidentifiedImageError as error:
self._log.debug(f"File '{file}' is not an image recognizable by PIL. {error}")
return False