From db4c19cc5815a082046dc531546531a4f8c6912c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 15 Jan 2017 00:15:33 +1100 Subject: [PATCH] Image: Added new backend for jp2a --- config/config | 2 +- neofetch | 44 +++++++++++++++++++++++++------------------- neofetch.1 | 2 +- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/config/config b/config/config index d14fe831..3969b332 100644 --- a/config/config +++ b/config/config @@ -529,7 +529,7 @@ disk_display="off" # Image backend. # # Default: 'ascii' -# Values: 'ascii', 'caca', 'catimg', 'iterm2', 'off', 'tycat', 'w3m' +# Values: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'tycat', 'w3m' # Flag: --image_backend image_backend="ascii" diff --git a/neofetch b/neofetch index c9491663..2c1abfe9 100755 --- a/neofetch +++ b/neofetch @@ -1954,7 +1954,7 @@ image_backend() { "ascii") get_ascii ;; "off") image_backend="off" ;; - "iterm2" | "w3m" | "tycat" | "catimg" | "caca") + "caca" | "catimg" | "jp2a" | "iterm2" | "tycat" | "w3m") get_image_source if [[ ! -f "$image" ]]; then @@ -1985,7 +1985,6 @@ image_backend() { err "Image: Falling back to ascii mode." get_ascii ;; - esac # Set cursor position next image/ascii. @@ -2339,14 +2338,22 @@ make_thumbnail() { display_image() { case "$image_backend" in - "w3m") - get_w3m_img_path + "caca") + 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 - # appearing in specific terminal emulators. - 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 "Images: w3m-img failed to display the image." + "catimg") + catimg -w "$columns" "$image" || to_off "Images: catimg failed to display the image." + text_padding="$((columns / 2 + gap))" + zws= + ;; + + "jp2a") + jp2a --width="$((width / font_width))" --colors "$image" || to_off "Images: jp2a failed to display the image." + text_padding="$((columns / 2 + gap))" + zws= ;; "iterm2") @@ -2357,16 +2364,14 @@ display_image() { tycat "$image" || to_off "Images: tycat failed to display the image." ;; - "catimg") - catimg -w "$columns" "$image" || to_off "Images: catimg failed to display the image." - text_padding="$((columns / 2 + gap))" - zws= - ;; + "w3m") + get_w3m_img_path - "caca") - 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 + # appearing in specific terminal emulators. + 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 "Images: w3m-img failed to display the image." ;; esac } @@ -3706,7 +3711,7 @@ BARS: IMAGE BACKEND: --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. Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/' --ascii Shortcut to use 'ascii' backend. @@ -3916,6 +3921,7 @@ get_args() { "--ascii") image_backend="ascii" ;; "--caca") image_backend="caca" ;; "--catimg") image_backend="catimg" ;; + "--jp2a") image_backend="jp2a" ;; "--iterm2") image_backend="iterm2" ;; "--off") image_backend="off" ;; "--tycat") image_backend="tycat" ;; diff --git a/neofetch.1 b/neofetch.1 index 57ad4ad1..cd25dcac 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -175,7 +175,7 @@ Takes: bar, infobar, barinfo, off .TP \fB\-\-image_backend\fR 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' .TP \fB\-\-image_source\fR source Which image or ascii file to use.