[READ-ONLY] Mirror of https://github.com/mrgnw/scripts.
0

Configure Feed

Select the types of activity you want to include in your feed.

avifs: replace optimizt with avifenc + parallel

optimizt (Node.js) was slow and single-threaded. Now uses avifenc
(libaom) with GNU parallel for file-level parallelism across all cores.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+40
+40
avifs
··· 1 + #!/usr/bin/env zsh 2 + set -euo pipefail 3 + setopt nocaseglob 4 + 5 + trash=false 6 + positional=() 7 + for arg in "$@"; do 8 + case $arg in 9 + -t|--trash) trash=true ;; 10 + *) positional+=("$arg") ;; 11 + esac 12 + done 13 + 14 + if [[ ${#positional[@]} -gt 0 ]]; then 15 + files=("${positional[@]}") 16 + else 17 + extensions=(${(f)"$(globs images -x avif)"}) 18 + files=() 19 + for ext in "${extensions[@]}"; do 20 + files+=(${~ext}(N)) 21 + done 22 + fi 23 + if [[ ${#files[@]} -eq 0 ]]; then 24 + echo "No image files found." >&2 25 + echo "Usage: avifs [-t|--trash] [file ...]" >&2 26 + exit 1 27 + fi 28 + 29 + printf '%s\0' "${files[@]}" | parallel -0 'avifenc -j 1 --speed 6 {} {.}.avif' 30 + 31 + if $trash; then 32 + for f in "${files[@]}"; do 33 + base="${f%.*}" 34 + if [[ -f "${base}.avif" ]]; then 35 + mv "$f" ~/.Trash/ 36 + else 37 + echo "Skipping trash for $f (no .avif output found)" >&2 38 + fi 39 + done 40 + fi