check for read error
This commit is contained in:
parent
d22c20614e
commit
824787b860
1 changed files with 3 additions and 0 deletions
|
@ -178,6 +178,9 @@ class image_classifier:
|
||||||
def is_image(self, file):
|
def is_image(self, file):
|
||||||
try:
|
try:
|
||||||
image_object = PIL.Image.open(file)
|
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:
|
except PIL.UnidentifiedImageError as error:
|
||||||
self._log.debug(f"File '{file}' is not an image recognizable by PIL. {error}")
|
self._log.debug(f"File '{file}' is not an image recognizable by PIL. {error}")
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in a new issue