From 7998944a716977cdf9b8cab1025d8db51794fe1a Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Tue, 21 Jan 2025 19:23:14 -0800 Subject: [PATCH] Import pillow plugins --- comictaggerlib/main.py | 3 ++- comictaggerlib/pillow_plugins.py | 14 ++++++++++++++ comictaggerlib/ui/qtutils.py | 3 +-- 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 comictaggerlib/pillow_plugins.py diff --git a/comictaggerlib/main.py b/comictaggerlib/main.py index 7c598c7..9e59891 100644 --- a/comictaggerlib/main.py +++ b/comictaggerlib/main.py @@ -33,7 +33,7 @@ import settngs import comicapi.comicarchive import comicapi.utils import comictalker -from comictaggerlib import cli, ctsettings +from comictaggerlib import cli, ctsettings, pillow_plugins from comictaggerlib.ctsettings import ct_ns, plugin_finder from comictaggerlib.ctversion import version from comictaggerlib.log import setup_logging @@ -48,6 +48,7 @@ logger = logging.getLogger("comictagger") logger.setLevel(logging.DEBUG) +assert pillow_plugins def _lang_code_mac() -> str: diff --git a/comictaggerlib/pillow_plugins.py b/comictaggerlib/pillow_plugins.py new file mode 100644 index 0000000..559a74c --- /dev/null +++ b/comictaggerlib/pillow_plugins.py @@ -0,0 +1,14 @@ +from __future__ import annotations + +try: + import pillow_avif + + assert pillow_avif +except ImportError: + pass +try: + import pillow_jxl + + assert pillow_jxl +except ImportError: + pass diff --git a/comictaggerlib/ui/qtutils.py b/comictaggerlib/ui/qtutils.py index 51b3374..d061d65 100644 --- a/comictaggerlib/ui/qtutils.py +++ b/comictaggerlib/ui/qtutils.py @@ -130,11 +130,10 @@ if qt_available: if pil_available: # Qt doesn't understand the format, but maybe PIL does buffer = io.BytesIO() - Image.open(io.BytesIO(image_data)).save(buffer, format='ppm') + Image.open(io.BytesIO(image_data)).save(buffer, format="ppm") success = img.loadFromData(buffer.getvalue()) except Exception: logger.exception("Failed to load the image") - pass # if still nothing, go with default image if not success: img.load(":/graphics/nocover.png")