keep transparency in thumbnails

This commit is contained in:
ed 2021-06-12 03:32:06 +02:00
parent f156e00064
commit aa12830015
3 changed files with 13 additions and 5 deletions

View file

@ -244,8 +244,8 @@ class ThumbSrv(object):
except: except:
im.thumbnail(self.res) im.thumbnail(self.res)
if im.mode not in ("RGB", "L"): fmts = ["RGB", "L"]
im = im.convert("RGB") args = {"quality": 40}
if tpath.endswith(".webp"): if tpath.endswith(".webp"):
# quality 80 = pillow-default # quality 80 = pillow-default
@ -253,9 +253,16 @@ class ThumbSrv(object):
# method 0 = pillow-default, fast # method 0 = pillow-default, fast
# method 4 = ffmpeg-default # method 4 = ffmpeg-default
# method 6 = max, slow # method 6 = max, slow
im.save(tpath, quality=40, method=6) fmts += ["RGBA", "LA"]
args["method"] = 6
else: 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): def conv_ffmpeg(self, abspath, tpath):
ret, _ = ffprobe(abspath) ret, _ = ffprobe(abspath)

View file

@ -917,6 +917,7 @@ html.light #files {
} }
html.light #files thead th { html.light #files thead th {
background: #eee; background: #eee;
border-radius: 0;
} }
html.light #files tr td { html.light #files tr td {
border-top: 1px solid #ddd; border-top: 1px solid #ddd;

View file

@ -38,7 +38,7 @@ var have_webp = null;
img.onerror = function () { img.onerror = function () {
have_webp = false; have_webp = false;
}; };
img.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA"; img.src = "data:image/webp;base64,UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA==";
})(); })();