From 10aad31b32a7dd3f6f54822f66c72ab5cde75f6a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 11 Apr 2025 15:07:39 +0200 Subject: [PATCH 1/2] fix jpeg detection --- ayon_api/utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ayon_api/utils.py b/ayon_api/utils.py index bd391b3cb..11d5c8d99 100644 --- a/ayon_api/utils.py +++ b/ayon_api/utils.py @@ -855,11 +855,11 @@ def _get_media_mime_type_for_content_base(content: bytes) -> Optional[str]: if content[0:4] == b"\211PNG": return "image/png" - # JPEG, JFIF or Exif - if ( - content[0:4] == b"\xff\xd8\xff\xdb" - or content[6:10] in (b"JFIF", b"Exif") - ): + # JPEG + # - [0:2] is constant b"\xff\xd8" + # - [2:4] Marker identifier b"\xff{?}" + # NOTE: File ends with b"\xff\xd9" + if content[0:3] == b"\xff\xd8\xff": return "image/jpeg" # Webp From 73c2d8d38a61b1daf4d06b6bd9ed90976d7b2c98 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 11 Apr 2025 15:08:24 +0200 Subject: [PATCH 2/2] added references --- ayon_api/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ayon_api/utils.py b/ayon_api/utils.py index 11d5c8d99..5529f121f 100644 --- a/ayon_api/utils.py +++ b/ayon_api/utils.py @@ -857,7 +857,9 @@ def _get_media_mime_type_for_content_base(content: bytes) -> Optional[str]: # JPEG # - [0:2] is constant b"\xff\xd8" + # (ref. https://www.file-recovery.com/jpg-signature-format.htm) # - [2:4] Marker identifier b"\xff{?}" + # (ref. https://www.disktuna.com/list-of-jpeg-markers/) # NOTE: File ends with b"\xff\xd9" if content[0:3] == b"\xff\xd8\xff": return "image/jpeg"