Commit 6c56358
xxwhirlpool
·
2026-07-25 17:18:07 -0400 EDT
parent dd69d1f
dither.sh + misc
11 files changed,
+40,
-5
+3,
-0
1@@ -181,6 +181,9 @@ PERL_MM_OPT="INSTALL_BASE=/home/kat/.perl5"; export PERL_MM_OPT;
2 # golang shit
3 export GOPATH="$HOME/.go"
4
5+# editor
6+export EDITOR="/usr/bin/micro"
7+
8 ######################################
9 # functions
10 ######################################
+1,
-0
1@@ -3573,3 +3573,4 @@
2 🫶 heart hands
3 🥲 single tear smile
4 🫵 index pointing at viewer
5+🫠melting melty face
+1,
-1
1@@ -3,4 +3,4 @@
2 cmd="$1"
3 editfile=$(command -v "$cmd")
4
5-[[ -f "$editfile" ]] && micro "$editfile" || echo "$1 does not exist"
6+[[ -f "$editfile" ]] && "$EDITOR" "$editfile" || echo "$1 does not exist"
+2,
-2
1@@ -4,7 +4,7 @@
2
3 file="$(mktemp --suffix _scratchpad)"
4
5-micro "$file"
6+"$EDITOR" "$file"
7
8-gum_echo "FILEPATH:"
9+gum_echo "FILEPATH: " | tr -d "\n"
10 realpath "$file" | lolcat -p 1.5
+2,
-2
1@@ -16,10 +16,10 @@ default() {
2 }
3
4 openfile() {
5- mv "$cmd" "$localpath" && micro "$localpath/$cmd"
6+ mv "$cmd" "$localpath" && "$EDITOR" "$localpath/$cmd"
7 }
8
9 case "$1" in
10 "-b") cmd="$2"; default "$@" && openfile "$@";;
11- *) default "$@" && micro "$cmd";;
12+ *) default "$@" && "$EDITOR" "$cmd";;
13 esac
+5,
-0
1@@ -0,0 +1,5 @@
2+*.jpeg
3+*.jpg
4+*.png
5+*.webp
6+!palettes_dither/*
+26,
-0
1@@ -0,0 +1,26 @@
2+#!/usr/bin/env bash
3+#
4+# dither images in monochrome
5+#
6+# inspired by this blog:
7+# https://dead.garden/blog/how-my-images-are-dithered.html
8+
9+if [[ "$#" -eq 0 ]]; then
10+ echo "usage: dither.sh [FILENAME]"
11+ exit 1
12+fi
13+
14+# vars
15+img="$1"
16+imgorig="${img%.*}_orig.${img##*.}"
17+imgnew="${img%.*}_dither.${img##*.}"
18+
19+# cp img so there's a backup
20+cp "$img" "$imgorig"
21+
22+# pick color palette as
23+# described in filenames
24+palette=$(gum file "./dither")
25+
26+# do the conversion
27+magick "$imgorig" -resize 800 -set option:distort:viewport '%wx%h+0+0' -colorspace CMYK -separate null: \( -size 2x2 xc: \( +clone -negate \) +append \( +clone -negate \) -append \) -virtual-pixel tile -filter gaussian \( +clone -distort SRT 1,0 \) +swap \( +clone -distort SRT 1,15 \) +swap \( +clone -distort SRT 1,45 \) +swap \( +clone -distort SRT 1,75 \) +swap +delete -compose Overlay -layers composite -set colorspace CMYK -combine -remap "$palette" -colors 32 "$imgnew"