diff --git a/copyparty/svchub.py b/copyparty/svchub.py index cf0340e9..ab02cbb3 100644 --- a/copyparty/svchub.py +++ b/copyparty/svchub.py @@ -35,14 +35,14 @@ from .mtag import HAVE_FFMPEG, HAVE_FFPROBE, HAVE_MUTAGEN from .pwhash import HAVE_ARGON2 from .tcpsrv import TcpSrv from .th_srv import ( - HAVE_AVIF, + H_PIL_AVIF, + H_PIL_HEIF, + H_PIL_WEBP, HAVE_FFMPEG, HAVE_FFPROBE, - HAVE_HEIF, HAVE_PIL, HAVE_RAW, HAVE_VIPS, - HAVE_WEBP, ThumbSrv, ) from .up2k import Up2k @@ -371,10 +371,6 @@ class SvcHub(object): t = ", ".join(self.args.th_dec) or "(None available)" self.log("thumb", "decoder preference: {}".format(t)) - if "pil" in self.args.th_dec and not HAVE_WEBP: - msg = "disabling webp thumbnails because either libwebp is not available or your Pillow is too old" - self.log("thumb", msg, c=3) - if self.args.th_dec: self.thumbsrv = ThumbSrv(self) else: @@ -954,14 +950,14 @@ class SvcHub(object): (HAVE_SQLITE3, "sqlite", "sessions and file/media indexing"), (HAVE_PIL, "pillow", "image thumbnails (plenty fast)"), (HAVE_VIPS, "vips", "image thumbnails (faster, eats more ram)"), - (HAVE_WEBP, "pillow-webp", "create thumbnails as webp files"), + (H_PIL_WEBP, "pillow-webp", "create thumbnails as webp files"), (HAVE_FFMPEG, "ffmpeg", t_ff + ", good-but-slow image thumbnails"), (HAVE_FFPROBE, "ffprobe", t_ff + ", read audio/media tags"), (HAVE_MUTAGEN, "mutagen", "read audio tags (ffprobe is better but slower)"), (HAVE_ARGON2, "argon2", "secure password hashing (advanced users only)"), (HAVE_ZMQ, "pyzmq", "send zeromq messages from event-hooks"), - (HAVE_HEIF, "pillow-heif", "read .heif images with pillow (rarely useful)"), - (HAVE_AVIF, "pillow-avif", "read .avif images with pillow (rarely useful)"), + (H_PIL_HEIF, "pillow-heif", "read .heif pics with pillow (rarely useful)"), + (H_PIL_AVIF, "pillow-avif", "read .avif pics with pillow (rarely useful)"), (HAVE_RAW, "rawpy", "read RAW images"), ] if ANYWIN: diff --git a/copyparty/th_cli.py b/copyparty/th_cli.py index 2b860f4c..f2a1379c 100644 --- a/copyparty/th_cli.py +++ b/copyparty/th_cli.py @@ -8,7 +8,7 @@ import stat from .__init__ import TYPE_CHECKING from .authsrv import VFS from .bos import bos -from .th_srv import EXTS_AC, HAVE_JXL, HAVE_WEBP, thumb_path +from .th_srv import EXTS_AC, H_PIL_JXL, H_PIL_WEBP, thumb_path from .util import Cooldown, Pebkac if True: # pylint: disable=using-constant-test @@ -53,8 +53,8 @@ class ThumbCli(object): # defer args.th_ff_jpg, can change at runtime nonpil = next((x for x in self.args.th_dec if x in ("vips", "ff")), None) - self.can_webp = HAVE_WEBP or nonpil - self.can_jxl = HAVE_JXL or nonpil + self.can_webp = H_PIL_WEBP or nonpil + self.can_jxl = H_PIL_JXL or nonpil def log(self, msg: str, c: Union[int, str] = 0) -> None: self.log_func("thumbcli", msg, c) diff --git a/copyparty/th_srv.py b/copyparty/th_srv.py index 3cfdd3c9..7d461579 100644 --- a/copyparty/th_srv.py +++ b/copyparty/th_srv.py @@ -46,10 +46,10 @@ if PY2: HAVE_PIL = False HAVE_PILF = False -HAVE_HEIF = False -HAVE_AVIF = False -HAVE_WEBP = False -HAVE_JXL = False +H_PIL_HEIF = False +H_PIL_AVIF = False +H_PIL_WEBP = False +H_PIL_JXL = False TH_CH = {"j": "jpg", "p": "png", "w": "webp", "x": "jxl"} @@ -131,7 +131,7 @@ try: raise Exception() Image.new("RGB", (2, 2)).save(BytesIO(), format="webp") - HAVE_WEBP = True + H_PIL_WEBP = True except: pass @@ -145,7 +145,7 @@ try: pass Image.new("RGB", (2, 2)).save(BytesIO(), format="jxl") - HAVE_JXL = True + H_PIL_JXL = True except: pass @@ -159,7 +159,7 @@ try: from pyheif_pillow_opener import register_heif_opener register_heif_opener() - HAVE_HEIF = True + H_PIL_HEIF = True except: pass @@ -168,12 +168,12 @@ try: raise Exception() if ".avif" in Image.registered_extensions(): - HAVE_AVIF = True + H_PIL_AVIF = True raise Exception() import pillow_avif # noqa: F401 # pylint: disable=unused-import - HAVE_AVIF = True + H_PIL_AVIF = True except: pass @@ -309,19 +309,19 @@ class ThumbSrv(object): ] ] - if not HAVE_HEIF: + if not H_PIL_HEIF: for f in "heif heifs heic heics".split(" "): self.fmt_pil.discard(f) - if not HAVE_AVIF: + if not H_PIL_AVIF: for f in "avif avifs".split(" "): self.fmt_pil.discard(f) - if not HAVE_WEBP: + if not H_PIL_WEBP: for f in "webp".split(" "): self.fmt_pil.discard(f) - if not HAVE_JXL: + if not H_PIL_JXL: for f in "jxl".split(" "): self.fmt_pil.discard(f) @@ -514,7 +514,7 @@ class ThumbSrv(object): ext in self.fmt_ffa or ext in self.fmt_ffv ) - if lib == "pil" and ext in self.fmt_pil: + if lib == "pil" and ext in self.fmt_pil and tex in self.fmt_pil: funs.append(self.conv_pil) elif lib == "vips" and ext in self.fmt_vips: funs.append(self.conv_vips)