From 169593ea3689e50388dbda13984cbb9bc3d7ce1c Mon Sep 17 00:00:00 2001 From: Ruin0x11 Date: Fri, 7 May 2021 14:36:58 -0700 Subject: Add AVIF/HEIC detection ffmpeg doesn't support HEIC decoding yet... --- server/szurubooru/func/mime.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'server/szurubooru/func/mime.py') diff --git a/server/szurubooru/func/mime.py b/server/szurubooru/func/mime.py index bd553fc..f1d9fbb 100644 --- a/server/szurubooru/func/mime.py +++ b/server/szurubooru/func/mime.py @@ -21,6 +21,12 @@ def get_mime_type(content: bytes) -> str: if content[8:12] == b"WEBP": return "image/webp" + if content[4:12] in (b"ftypavif", b"ftypavis"): + return "image/avif" + + if content[4:12] in (b"ftypheic", b"ftypmif1"): + return "image/heic" + if content[0:4] == b"\x1A\x45\xDF\xA3": return "video/webm" @@ -37,6 +43,8 @@ def get_extension(mime_type: str) -> Optional[str]: "image/jpeg": "jpg", "image/png": "png", "image/webp": "webp", + "image/avif": "avif", + "image/heic": "heic", "video/mp4": "mp4", "video/webm": "webm", "application/octet-stream": "dat", @@ -58,6 +66,8 @@ def is_image(mime_type: str) -> bool: "image/png", "image/gif", "image/webp", + "image/avif", + "image/heic", ) -- cgit v1.3