Diff
1diff --git a/plugins/catimg/README.md b/plugins/catimg/README.md
2index 68dc33c1f429cac40485032d1e998dca91570ab2..4cfda0e25e9d09c601f9d392c6af925887ea259e 100644
3--- a/plugins/catimg/README.md
4+++ b/plugins/catimg/README.md
5@@ -1,6 +1,7 @@
6 # catimg
7
8-Plugin for displaying images on the terminal using the `catimg.sh` script provided by [posva](https://github.com/posva/catimg)
9+Plugin for displaying images on the terminal using the `catimg.sh` script provided by
10+[posva](https://github.com/posva/catimg)
11
12 To use it, add `catimg` to the plugins array in your zshrc file:
13
14@@ -10,7 +11,7 @@ plugins=(... catimg)
15
16 ## Requirements
17
18-- `convert` (ImageMagick)
19+- `magick convert` (ImageMagick)
20
21 ## Functions
22
23diff --git a/plugins/catimg/catimg.plugin.zsh b/plugins/catimg/catimg.plugin.zsh
24index f4ff6f8562b6a7c537baf8b91dca139c1fb6faf3..ad10d857458e167416bcdec3b86f73da93a5170f 100644
25--- a/plugins/catimg/catimg.plugin.zsh
26+++ b/plugins/catimg/catimg.plugin.zsh
27@@ -9,9 +9,11 @@
28
29
30 function catimg() {
31- if [[ -x `which convert` ]]; then
32- zsh $ZSH/plugins/catimg/catimg.sh $@
33+ if (( $+commands[magick] )); then
34+ CONVERT_CMD="magick" zsh $ZSH/plugins/catimg/catimg.sh $@
35+ elif (( $+commands[convert] )); then
36+ CONVERT_CMD="convert" zsh $ZSH/plugins/catimg/catimg.sh $@
37 else
38- echo "catimg need convert (ImageMagick) to work)"
39+ echo "catimg need magick/convert (ImageMagick) to work)"
40 fi
41 }
42diff --git a/plugins/catimg/catimg.sh b/plugins/catimg/catimg.sh
43index f583924282c3e14c7cb92738375587c8e75752a2..7946ad16e38622ae3bc6759358d140c7c58002bd 100644
44--- a/plugins/catimg/catimg.sh
45+++ b/plugins/catimg/catimg.sh
46@@ -7,6 +7,10 @@
47 # GitHub: https://github.com/posva/catimg #
48 ################################################################################
49
50+# this should come from outside, either `magick` or `convert`
51+# from imagemagick v7 and ahead `convert` is deprecated
52+: ${CONVERT_CMD:=convert}
53+
54 function help() {
55 echo "Usage catimg [-h] [-w width] [-c char] img"
56 echo "By default char is \" \" and w is the terminal width"
57@@ -43,23 +47,23 @@ if [ ! "$WIDTH" ]; then
58 else
59 COLS=$(expr $WIDTH "/" $(echo -n "$CHAR" | wc -c))
60 fi
61-WIDTH=$(convert "$IMG" -print "%w\n" /dev/null)
62+WIDTH=$($CONVERT_CMD "$IMG" -print "%w\n" /dev/null)
63 if [ "$WIDTH" -gt "$COLS" ]; then
64 WIDTH=$COLS
65 fi
66
67 REMAP=""
68-if convert "$IMG" -resize $COLS\> +dither -remap $COLOR_FILE /dev/null ; then
69+if $CONVERT_CMD "$IMG" -resize $COLS\> +dither -remap $COLOR_FILE /dev/null ; then
70 REMAP="-remap $COLOR_FILE"
71 else
72 echo "The version of convert is too old, don't expect good results :(" >&2
73- #convert "$IMG" -colors 256 PNG8:tmp.png
74- #IMG="tmp.png"
75+ # $CONVERT_CMD "$IMG" -colors 256 PNG8:tmp.png
76+ # IMG="tmp.png"
77 fi
78
79 # Display the image
80 I=0
81-convert "$IMG" -resize $COLS\> +dither `echo $REMAP` txt:- 2>/dev/null |
82+$CONVERT_CMD "$IMG" -resize $COLS\> +dither `echo $REMAP` txt:- 2>/dev/null |
83 sed -e 's/.*none.*/NO NO NO/g' -e '1d;s/^.*(\(.*\)[,)].*$/\1/g;y/,/ /' |
84 while read R G B f; do
85 if [ ! "$R" = "NO" ]; then