diff options
| author | Shyam Sunder <sgsunder1@gmail.com> | 2021-09-13 12:58:28 -0400 |
|---|---|---|
| committer | Shyam Sunder <sgsunder1@gmail.com> | 2021-09-13 13:25:37 -0400 |
| commit | e4a253fd2579719add519efa83c2aa28e3cb9a92 (patch) | |
| tree | 10b1abb2bd3f7a67885135bd12d77dee471049bb /server | |
| parent | 414106a4773d3a532e0903b6ee9524ca78c5e6ad (diff) | |
client+server: fixed style errors
Diffstat (limited to 'server')
| -rw-r--r-- | server/szurubooru/func/image_hash.py | 5 | ||||
| -rw-r--r-- | server/szurubooru/func/images.py | 3 | ||||
| -rw-r--r-- | server/szurubooru/func/mime.py | 1 |
3 files changed, 6 insertions, 3 deletions
diff --git a/server/szurubooru/func/image_hash.py b/server/szurubooru/func/image_hash.py index a445e62..05b27a4 100644 --- a/server/szurubooru/func/image_hash.py +++ b/server/szurubooru/func/image_hash.py @@ -5,14 +5,15 @@ from io import BytesIO from typing import Any, Callable, List, Optional, Set, Tuple import numpy as np -from PIL import Image import pillow_avif import pyheif +from PIL import Image from pyheif_pillow_opener import register_heif_opener -register_heif_opener() from szurubooru import config, errors +register_heif_opener() + logger = logging.getLogger(__name__) # Math based on paper from H. Chi Wong, Marshall Bern and David Goldberg diff --git a/server/szurubooru/func/images.py b/server/szurubooru/func/images.py index 101bba8..de41222 100644 --- a/server/szurubooru/func/images.py +++ b/server/szurubooru/func/images.py @@ -6,6 +6,7 @@ import shlex import subprocess from io import BytesIO from typing import List + from PIL import Image as PILImage from szurubooru import errors @@ -17,7 +18,7 @@ logger = logging.getLogger(__name__) def convert_heif_to_png(content: bytes) -> bytes: img = PILImage.open(BytesIO(content)) img_byte_arr = BytesIO() - img.save(img_byte_arr, format='PNG') + img.save(img_byte_arr, format="PNG") return img_byte_arr.getvalue() diff --git a/server/szurubooru/func/mime.py b/server/szurubooru/func/mime.py index 93c096b..3be43f7 100644 --- a/server/szurubooru/func/mime.py +++ b/server/szurubooru/func/mime.py @@ -88,6 +88,7 @@ def is_animated_gif(content: bytes) -> bool: and len(re.findall(pattern, content)) > 1 ) + def is_heif(mime_type: str) -> bool: return mime_type.lower() in ( "image/heif", |