From 0185d9920b7d6c380277a4a15c9e4818df41700a Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 9 Dec 2013 08:54:38 +0100 Subject: catimg plugin allow to print an image to the stdout using convert --- plugins/catimg/catimg.plugin.zsh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 plugins/catimg/catimg.plugin.zsh (limited to 'plugins/catimg/catimg.plugin.zsh') diff --git a/plugins/catimg/catimg.plugin.zsh b/plugins/catimg/catimg.plugin.zsh new file mode 100644 index 000000000..01e81eca7 --- /dev/null +++ b/plugins/catimg/catimg.plugin.zsh @@ -0,0 +1,16 @@ +################################################################################ +# catimg script by Eduardo San Martin Morote aka Posva # +# http://posva.net # +# # +# Ouput the content of an image to the stdout using the 256 colors of the # +# terminal. # +# Github: https://github.com/posva/catimg # +################################################################################ + +if [[ -x `which convert` ]]; then + function catimg() { + source $(dirname $0)/catimg.sh $@ + } +else + echo "catimg need convert (ImageMagick) to work)" +fi -- cgit v1.2.3-70-g09d2 From 349fa15b187a1b2c411db90f2022013caf3479e8 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 9 Dec 2013 22:07:19 +0100 Subject: Fixed a dirs bug for catimg --- plugins/catimg/catimg.plugin.zsh | 2 +- plugins/catimg/catimg.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins/catimg/catimg.plugin.zsh') diff --git a/plugins/catimg/catimg.plugin.zsh b/plugins/catimg/catimg.plugin.zsh index 01e81eca7..ee721cd03 100644 --- a/plugins/catimg/catimg.plugin.zsh +++ b/plugins/catimg/catimg.plugin.zsh @@ -9,7 +9,7 @@ if [[ -x `which convert` ]]; then function catimg() { - source $(dirname $0)/catimg.sh $@ + source $ZSH/plugins/catimg/catimg.sh $@ } else echo "catimg need convert (ImageMagick) to work)" diff --git a/plugins/catimg/catimg.sh b/plugins/catimg/catimg.sh index f9e067e34..c05fddcd4 100755 --- a/plugins/catimg/catimg.sh +++ b/plugins/catimg/catimg.sh @@ -43,7 +43,7 @@ if [ ! "$WIDTH" ]; then else COLS=$(expr $WIDTH "/" $(echo -n "$CHAR" | wc -c)) fi -WIDTH=$(convert ${IMG} -print "%w\n" /dev/null) +WIDTH=$(convert "$IMG" -print "%w\n" /dev/null) if [ "$WIDTH" -gt "$COLS" ]; then WIDTH=$COLS fi @@ -58,6 +58,7 @@ else fi # Display the image +I=0 convert "$IMG" -resize $COLS\> +dither `echo $REMAP` txt:- | sed -e 's/.*none.*/NO NO NO/g' -e '1d;s/^.*(\(.*\)[,)].*$/\1/g;y/,/ /' | while read R G B f; do -- cgit v1.2.3-70-g09d2 From 44b23ae194a1580a6af6d692e4ba268d61828929 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 9 Dec 2013 22:18:20 +0100 Subject: catimg: fix exit without using source supresses errors from convert whilen converting, as they are usually just warnings --- plugins/catimg/catimg.plugin.zsh | 2 +- plugins/catimg/catimg.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/catimg/catimg.plugin.zsh') diff --git a/plugins/catimg/catimg.plugin.zsh b/plugins/catimg/catimg.plugin.zsh index ee721cd03..70ef9a63c 100644 --- a/plugins/catimg/catimg.plugin.zsh +++ b/plugins/catimg/catimg.plugin.zsh @@ -9,7 +9,7 @@ if [[ -x `which convert` ]]; then function catimg() { - source $ZSH/plugins/catimg/catimg.sh $@ + zsh $ZSH/plugins/catimg/catimg.sh $@ } else echo "catimg need convert (ImageMagick) to work)" diff --git a/plugins/catimg/catimg.sh b/plugins/catimg/catimg.sh index c05fddcd4..cd0f2e333 100755 --- a/plugins/catimg/catimg.sh +++ b/plugins/catimg/catimg.sh @@ -59,7 +59,7 @@ fi # Display the image I=0 -convert "$IMG" -resize $COLS\> +dither `echo $REMAP` txt:- | +convert "$IMG" -resize $COLS\> +dither `echo $REMAP` txt:- 2>/dev/null | sed -e 's/.*none.*/NO NO NO/g' -e '1d;s/^.*(\(.*\)[,)].*$/\1/g;y/,/ /' | while read R G B f; do if [ ! "$R" = "NO" ]; then -- cgit v1.2.3-70-g09d2 From 8309b0a19baa351d643194f897d59de7b3d3b3dd Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sun, 23 Feb 2014 10:07:26 +0100 Subject: Verification of convert inside the function Depending on when the path is declared this solution would work in any case --- plugins/catimg/catimg.plugin.zsh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'plugins/catimg/catimg.plugin.zsh') diff --git a/plugins/catimg/catimg.plugin.zsh b/plugins/catimg/catimg.plugin.zsh index 70ef9a63c..cb92f5986 100644 --- a/plugins/catimg/catimg.plugin.zsh +++ b/plugins/catimg/catimg.plugin.zsh @@ -7,10 +7,11 @@ # Github: https://github.com/posva/catimg # ################################################################################ -if [[ -x `which convert` ]]; then - function catimg() { + +function catimg() { + if [[ -x `which convert` ]]; then zsh $ZSH/plugins/catimg/catimg.sh $@ - } -else - echo "catimg need convert (ImageMagick) to work)" -fi + else + echo "catimg need convert (ImageMagick) to work)" + fi +} -- cgit v1.2.3-70-g09d2