From dadeeb6abdcab42e133f018717851858614c7075 Mon Sep 17 00:00:00 2001 From: Amras Date: Thu, 9 Nov 2023 16:44:27 +0100 Subject: [PATCH] Report exiftool errors Raise an exception when exiftool provides a Warning or Error, which usually indicates a corrupted file. This exception is handled by the allow_broken_uploads setting. --- server/szurubooru/func/images.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/szurubooru/func/images.py b/server/szurubooru/func/images.py index 1d55762b..c4d435ec 100644 --- a/server/szurubooru/func/images.py +++ b/server/szurubooru/func/images.py @@ -16,7 +16,6 @@ from szurubooru import errors from szurubooru.func import mime, util logger = logging.getLogger(__name__) -logger.setLevel(level=logging.INFO) # Refer to: # https://exiftool.org/TagNames/EXIF.html @@ -95,6 +94,8 @@ class Image: return None def _orientation_filter(self) -> str: + # This filter should be omitted in ffmpeg>=6.0, + # where it is automatically applied. try: return ORIENTATION_FILTER[self.info["Orientation"]] except KeyError: @@ -390,3 +391,11 @@ class Image: logger.warning("Unexpected output from exiftool") self.info = exiftool_data[0] + + if "Error" in self.info: + raise errors.ProcessingError( + "Error in metadata:" + str(self.info["Error"])) + + if "Warning" in self.info: + raise errors.ProcessingError( + "Warning in metadata:" + str(self.info["Warning"])) \ No newline at end of file