Commit 6c56358

xxwhirlpool  ·  2026-07-25 17:18:07 -0400 EDT
parent dd69d1f
dither.sh + misc
11 files changed,  +40, -5
+3, -0
......@@ -181,6 +181,9 @@ PERL_MM_OPT="INSTALL_BASE=/home/kat/.perl5"; export PERL_MM_OPT;
181181 # golang shit
182182 export GOPATH="$HOME/.go"
183183
184+# editor
185+export EDITOR="/usr/bin/micro"
186+
184187 ######################################
185188 # functions
186189 ######################################
+1, -0
......@@ -3573,3 +3573,4 @@
35733573 🫶 heart hands
35743574 🥲 single tear smile
35753575 🫵 index pointing at viewer
3576+🫠 melting melty face
+1, -1
......@@ -3,4 +3,4 @@
33 cmd="$1"
44 editfile=$(command -v "$cmd")
55
6-[[ -f "$editfile" ]] && micro "$editfile" || echo "$1 does not exist"
6+[[ -f "$editfile" ]] && "$EDITOR" "$editfile" || echo "$1 does not exist"
+2, -2
......@@ -4,7 +4,7 @@
44
55 file="$(mktemp --suffix _scratchpad)"
66
7-micro "$file"
7+"$EDITOR" "$file"
88
9-gum_echo "FILEPATH:"
9+gum_echo "FILEPATH: " | tr -d "\n"
1010 realpath "$file" | lolcat -p 1.5
+2, -2
......@@ -16,10 +16,10 @@ default() {
1616 }
1717
1818 openfile() {
19- mv "$cmd" "$localpath" && micro "$localpath/$cmd"
19+ mv "$cmd" "$localpath" && "$EDITOR" "$localpath/$cmd"
2020 }
2121
2222 case "$1" in
2323 "-b") cmd="$2"; default "$@" && openfile "$@";;
24- *) default "$@" && micro "$cmd";;
24+ *) default "$@" && "$EDITOR" "$cmd";;
2525 esac
+5, -0
......@@ -0,0 +1,5 @@
1+*.jpeg
2+*.jpg
3+*.png
4+*.webp
5+!palettes_dither/*
+26, -0
......@@ -0,0 +1,26 @@
1+#!/usr/bin/env bash
2+#
3+# dither images in monochrome
4+#
5+# inspired by this blog:
6+# https://dead.garden/blog/how-my-images-are-dithered.html
7+
8+if [[ "$#" -eq 0 ]]; then
9+ echo "usage: dither.sh [FILENAME]"
10+ exit 1
11+fi
12+
13+# vars
14+img="$1"
15+imgorig="${img%.*}_orig.${img##*.}"
16+imgnew="${img%.*}_dither.${img##*.}"
17+
18+# cp img so there's a backup
19+cp "$img" "$imgorig"
20+
21+# pick color palette as
22+# described in filenames
23+palette=$(gum file "./dither")
24+
25+# do the conversion
26+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"
+0, -0
Binaries are not rendered as diffs.
+0, -0
Binaries are not rendered as diffs.
+0, -0
Binaries are not rendered as diffs.
+0, -0
Binaries are not rendered as diffs.