summaryrefslogtreecommitdiff
path: root/server/szurubooru/func/mime.py
diff options
context:
space:
mode:
authorRuin0x11 <ipickering2@gmail.com>2021-05-07 14:36:58 -0700
committerRuin0x11 <ipickering2@gmail.com>2021-05-07 14:36:58 -0700
commit169593ea3689e50388dbda13984cbb9bc3d7ce1c (patch)
tree3f648fb5c002fe2a3002630a4207c4a35e457d20 /server/szurubooru/func/mime.py
parentca771495979b035ac670b850b10239b6e4f10dcc (diff)
Add AVIF/HEIC detection
ffmpeg doesn't support HEIC decoding yet...
Diffstat (limited to 'server/szurubooru/func/mime.py')
-rw-r--r--server/szurubooru/func/mime.py10
1 files changed, 10 insertions, 0 deletions
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",
)