Add check for image

This commit is contained in:
Antonio J. Delgado 2021-09-08 15:26:01 +03:00
parent 388545f613
commit ec0ebae683

View file

@ -72,6 +72,7 @@ class image_classifier:
if not os.access(file, os.R_OK): if not os.access(file, os.R_OK):
self._log.error(f"The file '{file}' is not readable.") self._log.error(f"The file '{file}' is not readable.")
else: else:
if self.is_image(file):
self.metadata = pyexiv2.ImageMetadata(file) self.metadata = pyexiv2.ImageMetadata(file)
self.metadata.read() self.metadata.read()
dirname = os.path.dirname(os.path.realpath(file)) dirname = os.path.dirname(os.path.realpath(file))
@ -107,6 +108,8 @@ class image_classifier:
shutil.move(file, new_path) shutil.move(file, new_path)
else: else:
self._log.info(f"NOT moving file '{file}' to '{new_path}' because of --no-move") self._log.info(f"NOT moving file '{file}' to '{new_path}' because of --no-move")
else:
self._log.debug(f"The file '{file}' is not an image.")
def print_metadata(self): def print_metadata(self):
print("IPTC keys:") print("IPTC keys:")