Fix: --animate option is not supported

This commit is contained in:
Nikita Ivanov 2022-06-24 12:57:06 +05:00
parent e2a2c531c7
commit 8e5141da3d
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133

View File

@ -40,7 +40,28 @@ set_image_method() {
is_kitty && { image_method="$image_method_kitty"; return 0; } is_kitty && { image_method="$image_method_kitty"; return 0; }
exists chafa && { image_method="$image_method_chafa"; return 0; } exists chafa && exists convert && { image_method="$image_method_chafa"; return 0; }
}
is_anim_image() {
case "$m" in
image/apng|image/gif|image/avif|image/webp)
return 0 ;;
*)
return 1 ;;
esac
}
prepare_anim_img() {
if [ "$1" != "$cache_f" ] && is_anim_image "$1"; then
convert "${1}[0]" "jpg:${cache_f}" && printf '%s\n' "$cache_f"
else
printf '%s\n' "$1"
fi
}
chafa_run() {
_f="$(prepare_anim_img "$1")" && chafa -s "${w}x${h}" "$_f"
} }
setup_fifo() { setup_fifo() {
@ -68,7 +89,7 @@ send_image() {
return 1 return 1
;; ;;
"$image_method_chafa") "$image_method_chafa")
chafa --animate off -s "${w}x${h}" "$1" chafa_run "$1"
;; ;;
*) *)
return 127 return 127