Skip to content

Commit fba7cce

Browse files
authored
Merge pull request #244 from ynput/bugfix/jpeg-detection-fix
Chore: Fix jpeg detection fix
2 parents da7837d + a3842dc commit fba7cce

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

ayon_api/utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -855,11 +855,13 @@ def _get_media_mime_type_for_content_base(content: bytes) -> Optional[str]:
855855
if content[0:4] == b"\211PNG":
856856
return "image/png"
857857

858-
# JPEG, JFIF or Exif
859-
if (
860-
content[0:4] == b"\xff\xd8\xff\xdb"
861-
or content[6:10] in (b"JFIF", b"Exif")
862-
):
858+
# JPEG
859+
# - [0:2] is constant b"\xff\xd8"
860+
# (ref. https://www.file-recovery.com/jpg-signature-format.htm)
861+
# - [2:4] Marker identifier b"\xff{?}"
862+
# (ref. https://www.disktuna.com/list-of-jpeg-markers/)
863+
# NOTE: File ends with b"\xff\xd9"
864+
if content[0:3] == b"\xff\xd8\xff":
863865
return "image/jpeg"
864866

865867
# Webp

0 commit comments

Comments
 (0)