Image: Added new backend for jp2a
This commit is contained in:
parent
d8712286f8
commit
db4c19cc58
|
@ -529,7 +529,7 @@ disk_display="off"
|
||||||
# Image backend.
|
# Image backend.
|
||||||
#
|
#
|
||||||
# Default: 'ascii'
|
# Default: 'ascii'
|
||||||
# Values: 'ascii', 'caca', 'catimg', 'iterm2', 'off', 'tycat', 'w3m'
|
# Values: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'tycat', 'w3m'
|
||||||
# Flag: --image_backend
|
# Flag: --image_backend
|
||||||
image_backend="ascii"
|
image_backend="ascii"
|
||||||
|
|
||||||
|
|
44
neofetch
44
neofetch
|
@ -1954,7 +1954,7 @@ image_backend() {
|
||||||
"ascii") get_ascii ;;
|
"ascii") get_ascii ;;
|
||||||
"off") image_backend="off" ;;
|
"off") image_backend="off" ;;
|
||||||
|
|
||||||
"iterm2" | "w3m" | "tycat" | "catimg" | "caca")
|
"caca" | "catimg" | "jp2a" | "iterm2" | "tycat" | "w3m")
|
||||||
get_image_source
|
get_image_source
|
||||||
|
|
||||||
if [[ ! -f "$image" ]]; then
|
if [[ ! -f "$image" ]]; then
|
||||||
|
@ -1985,7 +1985,6 @@ image_backend() {
|
||||||
err "Image: Falling back to ascii mode."
|
err "Image: Falling back to ascii mode."
|
||||||
get_ascii
|
get_ascii
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Set cursor position next image/ascii.
|
# Set cursor position next image/ascii.
|
||||||
|
@ -2339,14 +2338,22 @@ make_thumbnail() {
|
||||||
|
|
||||||
display_image() {
|
display_image() {
|
||||||
case "$image_backend" in
|
case "$image_backend" in
|
||||||
"w3m")
|
"caca")
|
||||||
get_w3m_img_path
|
img2txt -W "$((width / font_width))" -H "$((height / font_height))" --gamma=0.6 "$image" || to_off "Images: catimg failed to display the image."
|
||||||
|
text_padding="$((columns / 2 + gap))"
|
||||||
|
zws=
|
||||||
|
;;
|
||||||
|
|
||||||
# Add a tiny delay to fix issues with images not
|
"catimg")
|
||||||
# appearing in specific terminal emulators.
|
catimg -w "$columns" "$image" || to_off "Images: catimg failed to display the image."
|
||||||
sleep 0.05
|
text_padding="$((columns / 2 + gap))"
|
||||||
printf "%b\n" "0;1;$xoffset;$yoffset;$width;$height;;;;;$image\n4;\n3;" |\
|
zws=
|
||||||
"${w3m_img_path:-false}" -bg "$background_color" >/dev/null & 2>&1 || to_off "Images: w3m-img failed to display the image."
|
;;
|
||||||
|
|
||||||
|
"jp2a")
|
||||||
|
jp2a --width="$((width / font_width))" --colors "$image" || to_off "Images: jp2a failed to display the image."
|
||||||
|
text_padding="$((columns / 2 + gap))"
|
||||||
|
zws=
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"iterm2")
|
"iterm2")
|
||||||
|
@ -2357,16 +2364,14 @@ display_image() {
|
||||||
tycat "$image" || to_off "Images: tycat failed to display the image."
|
tycat "$image" || to_off "Images: tycat failed to display the image."
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"catimg")
|
"w3m")
|
||||||
catimg -w "$columns" "$image" || to_off "Images: catimg failed to display the image."
|
get_w3m_img_path
|
||||||
text_padding="$((columns / 2 + gap))"
|
|
||||||
zws=
|
|
||||||
;;
|
|
||||||
|
|
||||||
"caca")
|
# Add a tiny delay to fix issues with images not
|
||||||
img2txt -W "$((width / font_width))" -H "$((height / font_height))" --gamma=0.6 "$image" || to_off "Images: catimg failed to display the image."
|
# appearing in specific terminal emulators.
|
||||||
text_padding="$((columns / 2 + gap))"
|
sleep 0.05
|
||||||
zws=
|
printf "%b\n" "0;1;$xoffset;$yoffset;$width;$height;;;;;$image\n4;\n3;" |\
|
||||||
|
"${w3m_img_path:-false}" -bg "$background_color" >/dev/null & 2>&1 || to_off "Images: w3m-img failed to display the image."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -3706,7 +3711,7 @@ BARS:
|
||||||
|
|
||||||
IMAGE BACKEND:
|
IMAGE BACKEND:
|
||||||
--image_backend backend Which image backend to use.
|
--image_backend backend Which image backend to use.
|
||||||
Possible values: 'ascii', 'caca', 'catimg', 'iterm2', 'off', 'tycat', 'w3m'
|
Possible values: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'tycat', 'w3m'
|
||||||
--image_source source Which image or ascii file to use.
|
--image_source source Which image or ascii file to use.
|
||||||
Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
|
Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
|
||||||
--ascii Shortcut to use 'ascii' backend.
|
--ascii Shortcut to use 'ascii' backend.
|
||||||
|
@ -3916,6 +3921,7 @@ get_args() {
|
||||||
"--ascii") image_backend="ascii" ;;
|
"--ascii") image_backend="ascii" ;;
|
||||||
"--caca") image_backend="caca" ;;
|
"--caca") image_backend="caca" ;;
|
||||||
"--catimg") image_backend="catimg" ;;
|
"--catimg") image_backend="catimg" ;;
|
||||||
|
"--jp2a") image_backend="jp2a" ;;
|
||||||
"--iterm2") image_backend="iterm2" ;;
|
"--iterm2") image_backend="iterm2" ;;
|
||||||
"--off") image_backend="off" ;;
|
"--off") image_backend="off" ;;
|
||||||
"--tycat") image_backend="tycat" ;;
|
"--tycat") image_backend="tycat" ;;
|
||||||
|
|
|
@ -175,7 +175,7 @@ Takes: bar, infobar, barinfo, off
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-image_backend\fR backend
|
\fB\-\-image_backend\fR backend
|
||||||
Which image backend to use.
|
Which image backend to use.
|
||||||
Possible values: 'ascii', 'caca', 'catimg', 'iterm2', 'off', 'tycat', 'w3m'
|
Possible values: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'tycat', 'w3m'
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-image_source\fR source
|
\fB\-\-image_source\fR source
|
||||||
Which image or ascii file to use.
|
Which image or ascii file to use.
|
||||||
|
|
Reference in New Issue