mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
try next thumbnailer if one fails;
libvips assumes imagemagick was built with avif
This commit is contained in:
parent
b070d44de7
commit
6cf53d7364
|
@ -247,40 +247,40 @@ class ThumbSrv(object):
|
||||||
abspath, tpath = task
|
abspath, tpath = task
|
||||||
ext = abspath.split(".")[-1].lower()
|
ext = abspath.split(".")[-1].lower()
|
||||||
png_ok = False
|
png_ok = False
|
||||||
fun = None
|
funs = []
|
||||||
if not bos.path.exists(tpath):
|
if not bos.path.exists(tpath):
|
||||||
for lib in self.args.th_dec:
|
for lib in self.args.th_dec:
|
||||||
if fun:
|
if lib == "pil" and ext in self.fmt_pil:
|
||||||
break
|
funs.append(self.conv_pil)
|
||||||
elif lib == "pil" and ext in self.fmt_pil:
|
|
||||||
fun = self.conv_pil
|
|
||||||
elif lib == "vips" and ext in self.fmt_vips:
|
elif lib == "vips" and ext in self.fmt_vips:
|
||||||
fun = self.conv_vips
|
funs.append(self.conv_vips)
|
||||||
elif lib == "ff" and ext in self.fmt_ffi or ext in self.fmt_ffv:
|
elif lib == "ff" and ext in self.fmt_ffi or ext in self.fmt_ffv:
|
||||||
fun = self.conv_ffmpeg
|
funs.append(self.conv_ffmpeg)
|
||||||
elif lib == "ff" and ext in self.fmt_ffa:
|
elif lib == "ff" and ext in self.fmt_ffa:
|
||||||
if tpath.endswith(".opus") or tpath.endswith(".caf"):
|
if tpath.endswith(".opus") or tpath.endswith(".caf"):
|
||||||
fun = self.conv_opus
|
funs.append(self.conv_opus)
|
||||||
elif tpath.endswith(".png"):
|
elif tpath.endswith(".png"):
|
||||||
fun = self.conv_waves
|
funs.append(self.conv_waves)
|
||||||
png_ok = True
|
png_ok = True
|
||||||
else:
|
else:
|
||||||
fun = self.conv_spec
|
funs.append(self.conv_spec)
|
||||||
|
|
||||||
if not png_ok and tpath.endswith(".png"):
|
if not png_ok and tpath.endswith(".png"):
|
||||||
raise Pebkac(400, "png only allowed for waveforms")
|
raise Pebkac(400, "png only allowed for waveforms")
|
||||||
|
|
||||||
if fun:
|
for fun in funs:
|
||||||
try:
|
try:
|
||||||
fun(abspath, tpath)
|
fun(abspath, tpath)
|
||||||
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
msg = "{} could not create thumbnail of {}\n{}"
|
msg = "{} could not create thumbnail of {}\n{}"
|
||||||
msg = msg.format(fun.__name__, abspath, min_ex())
|
msg = msg.format(fun.__name__, abspath, min_ex())
|
||||||
c: Union[str, int] = 1 if "<Signals.SIG" in msg else "90"
|
c: Union[str, int] = 1 if "<Signals.SIG" in msg else "90"
|
||||||
self.log(msg, c)
|
self.log(msg, c)
|
||||||
if getattr(ex, "returncode", 0) != 321:
|
if getattr(ex, "returncode", 0) != 321:
|
||||||
with open(tpath, "wb") as _:
|
if fun == funs[-1]:
|
||||||
pass
|
with open(tpath, "wb") as _:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
# ffmpeg may spawn empty files on windows
|
# ffmpeg may spawn empty files on windows
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue