Add highlight function to occlude.sh
dkl9

dkl9 commited on 2023-185 07:17:49
Showing 1 changed files, with 12 additions and 1 deletions.

... ...
@@ -3,16 +3,27 @@
3 3
 # usage: occlude img
4 4
 # Displays img in iv and generates a numbered occluded image
5 5
 # for every two middle-clicks (which select a position in the image).
6
+# You can also use it as `highlight img` (with a symlink) and it will
7
+# highlight those rectangular sections instead of occluding them.
6 8
 
7 9
 IFS=', '
8 10
 BFN="${1%.*}"
9 11
 FE="${1##*.}"
10 12
 CTR=1
13
+MODE=`basename "$0"`
14
+MODE="${MODE%%.*}"
15
+if [ "$MODE" = occlude ]
16
+then
17
+    MARGS='-fill black'
18
+elif [ "$MODE" = highlight ]
19
+then
20
+    MARGS='-stroke black -strokewidth 1.5 -fill #c0ff0040'
21
+fi
11 22
 '/usr/local/bin/iv' "$1" | while read X Y
12 23
 do
13 24
     if [ -n "$SX" ]
14 25
     then
15
-        magick "$1" -fill black -draw "rectangle ${SX},${SY} ${X},${Y}" "${BFN}_${CTR}.${FE}"
26
+        magick "$1" $MARGS -draw "rectangle ${SX},${SY} ${X},${Y}" "${BFN}_${CTR}.${FE}"
16 27
         SX=''
17 28
         SY=''
18 29
         CTR="$((CTR+1))"
19 30