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; | |
| 181 | 181 | # golang shit | |
| 182 | 182 | export GOPATH="$HOME/.go" | |
| 183 | 183 | ||
| 184 | + | # editor | |
| 185 | + | export EDITOR="/usr/bin/micro" | |
| 186 | + | ||
| 184 | 187 | ###################################### | |
| 185 | 188 | # functions | |
| 186 | 189 | ###################################### |
+1,
-0
| ... | ... | @@ -3573,3 +3573,4 @@ | |
| 3573 | 3573 | 🫶 heart hands | |
| 3574 | 3574 | 🥲 single tear smile | |
| 3575 | 3575 | 🫵 index pointing at viewer | |
| 3576 | + | 🫠melting melty face |
+1,
-1
| ... | ... | @@ -3,4 +3,4 @@ | |
| 3 | 3 | cmd="$1" | |
| 4 | 4 | editfile=$(command -v "$cmd") | |
| 5 | 5 | ||
| 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 @@ | |
| 4 | 4 | ||
| 5 | 5 | file="$(mktemp --suffix _scratchpad)" | |
| 6 | 6 | ||
| 7 | - | micro "$file" | |
| 7 | + | "$EDITOR" "$file" | |
| 8 | 8 | ||
| 9 | - | gum_echo "FILEPATH:" | |
| 9 | + | gum_echo "FILEPATH: " | tr -d "\n" | |
| 10 | 10 | realpath "$file" | lolcat -p 1.5 |
+2,
-2
| ... | ... | @@ -16,10 +16,10 @@ default() { | |
| 16 | 16 | } | |
| 17 | 17 | ||
| 18 | 18 | openfile() { | |
| 19 | - | mv "$cmd" "$localpath" && micro "$localpath/$cmd" | |
| 19 | + | mv "$cmd" "$localpath" && "$EDITOR" "$localpath/$cmd" | |
| 20 | 20 | } | |
| 21 | 21 | ||
| 22 | 22 | case "$1" in | |
| 23 | 23 | "-b") cmd="$2"; default "$@" && openfile "$@";; | |
| 24 | - | *) default "$@" && micro "$cmd";; | |
| 24 | + | *) default "$@" && "$EDITOR" "$cmd";; | |
| 25 | 25 | esac |
+5,
-0
+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" |
Binaries are not rendered as diffs.
Binaries are not rendered as diffs.
Binaries are not rendered as diffs.
Binaries are not rendered as diffs.