improved image robustness

This commit is contained in:
Lionel Dricot 2022-02-11 12:01:05 +01:00
parent 4b39b7eac1
commit 9cdb52383d
1 changed files with 4 additions and 4 deletions

View File

@ -610,11 +610,11 @@ class HtmlRenderer():
if hasattr(img_obj,"n_frames") and img_obj.n_frames > 1: if hasattr(img_obj,"n_frames") and img_obj.n_frames > 1:
# we remove all frames but the first one # we remove all frames but the first one
img_obj.save(img,save_all=False) img_obj.save(img,save_all=False)
return_code = subprocess.run("chafa --bg white -s 40 %s -w 1"%img, \ cmd = "chafa --bg white -s 40 -w 1 \"%s\"" %img
shell=True, capture_output=True) return_code = subprocess.run(cmd,shell=True, capture_output=True)
ansi_img = return_code.stdout.decode() ansi_img = return_code.stdout.decode()
except: except Exception as err:
ansi_img = "***image failed***\n" ansi_img = "***image failed : %s***\n" %err
alt = element.get("alt") alt = element.get("alt")
if alt: if alt:
alt = sanitize_string(alt) alt = sanitize_string(alt)