Image: Added sixel backend

This commit is contained in:
Dylan Araps 2017-02-09 10:23:21 +11:00
parent 04d180c6f0
commit 69046ae124
1 changed files with 12 additions and 11 deletions

View File

@ -1985,7 +1985,7 @@ image_backend() {
"ascii") get_ascii ;;
"off") image_backend="off" ;;
"caca" | "catimg" | "jp2a" | "iterm2" | "tycat" | "w3m")
"caca" | "catimg" | "jp2a" | "iterm2" | "tycat" | "w3m" | "sixel")
get_image_source
if [[ ! -f "$image" ]]; then
@ -1997,7 +1997,6 @@ image_backend() {
if [[ "$term_width" ]] && ((term_width >= 1)); then
clear
zws=" "
else
to_ascii "Image: Failed to find terminal window size."
err "Image: Check the 'Images in the terminal' wiki page for more info,"
@ -2011,7 +2010,7 @@ image_backend() {
*)
err "Image: Unknown image backend specified '$image_backend'."
err "Image: Valid backends are: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'tycat', 'w3m')"
err "Image: Valid backends are: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'sixel', 'tycat', 'w3m')"
err "Image: Falling back to ascii mode."
get_ascii
;;
@ -2384,23 +2383,23 @@ make_thumbnail() {
display_image() {
case "$image_backend" in
"caca")
img2txt -W "$((width / font_width)))" -H "$((height / font_height))" --gamma=0.6 "$image" || to_off "Image: catimg failed to display the image."
zws=
img2txt -W "$((width / font_width)))" -H "$((height / font_height))" --gamma=0.6 "$image" || to_off "Image: libcaca failed to display the image."
;;
"catimg")
catimg -w "$((width * 2 / font_width))" -r 0 "$image" || to_off "Image: catimg failed to display the image."
zws=
;;
"jp2a")
jp2a --width="$((width / font_width))" --colors "$image" || to_off "Image: jp2a failed to display the image."
zws=
;;
"sixel")
img2sixel -w "$width" "$image" || to_off "Image: libsixel failed to display the image."
;;
"iterm2")
printf "%b\a\n" "\033]1337;File=width=${width}px;height=${height}px;inline=1:$(base64 < "$image")"
zws=
;;
"tycat")
@ -2415,6 +2414,8 @@ display_image() {
sleep 0.05
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 "Image: w3m-img failed to display the image."
zws=" "
;;
esac
}
@ -2438,7 +2439,6 @@ to_off() {
err "$1"
image_backend="off"
text_padding=
zws=
}
# SCREENSHOT
@ -3804,7 +3804,7 @@ BARS:
IMAGE BACKEND:
--backend backend Which image backend to use.
Possible values: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'tycat', 'w3m'
Possible values: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'sixel', 'tycat', 'w3m'
--source source Which image or ascii file to use.
Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
--ascii source Shortcut to use 'ascii' backend.
@ -3812,6 +3812,7 @@ IMAGE BACKEND:
--catimg source Shortcut to use 'catimg' backend.
--iterm2 source Shortcut to use 'iterm2' backend.
--jp2a source Shortcut to use 'jp2a' backend.
--sixel source Shortcut to use 'sixel' backend.
--tycat source Shortcut to use 'tycat' backend.
--w3m source Shortcut to use 'w3m' backend.
--off Shortcut to use 'off' backend.
@ -4014,7 +4015,7 @@ get_args() {
# Image backend
"--backend") image_backend="$2" ;;
"--source") image_source="$2" ;;
"--ascii" | "--caca" | "--catimg" | "--jp2a" | "--iterm2" | "--off" | "--tycat" | "--w3m")
"--ascii" | "--caca" | "--catimg" | "--jp2a" | "--iterm2" | "--off" | "--sixel" | "--tycat" | "--w3m")
image_backend="${1/--}"
case "$2" in
"-"* | "") ;;