From aa128300154be762a9fce5364acb054eb47679a1 Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 12 Jun 2021 03:32:06 +0200 Subject: [PATCH] keep transparency in thumbnails --- copyparty/th_srv.py | 15 +++++++++++---- copyparty/web/browser.css | 1 + copyparty/web/browser.js | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/copyparty/th_srv.py b/copyparty/th_srv.py index cc10d4c6..d28c3f8f 100644 --- a/copyparty/th_srv.py +++ b/copyparty/th_srv.py @@ -244,8 +244,8 @@ class ThumbSrv(object): except: im.thumbnail(self.res) - if im.mode not in ("RGB", "L"): - im = im.convert("RGB") + fmts = ["RGB", "L"] + args = {"quality": 40} if tpath.endswith(".webp"): # quality 80 = pillow-default @@ -253,9 +253,16 @@ class ThumbSrv(object): # method 0 = pillow-default, fast # method 4 = ffmpeg-default # method 6 = max, slow - im.save(tpath, quality=40, method=6) + fmts += ["RGBA", "LA"] + args["method"] = 6 else: - im.save(tpath, quality=40) # default=75 + pass # default q = 75 + + if im.mode not in fmts: + print("conv {}".format(im.mode)) + im = im.convert("RGB") + + im.save(tpath, quality=40, method=6) def conv_ffmpeg(self, abspath, tpath): ret, _ = ffprobe(abspath) diff --git a/copyparty/web/browser.css b/copyparty/web/browser.css index 6334692e..21fee194 100644 --- a/copyparty/web/browser.css +++ b/copyparty/web/browser.css @@ -917,6 +917,7 @@ html.light #files { } html.light #files thead th { background: #eee; + border-radius: 0; } html.light #files tr td { border-top: 1px solid #ddd; diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index b96af090..4329cd32 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -38,7 +38,7 @@ var have_webp = null; img.onerror = function () { have_webp = false; }; - img.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA"; + img.src = "data:image/webp;base64,UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA=="; })();