From 009f74ff4f0c42bcdd13b2864dbae127f4858baf Mon Sep 17 00:00:00 2001 From: Morgan Williams <2504532+mrgnw@users.noreply.github.com> Date: Tue, 31 Mar 2026 02:01:05 +0200 Subject: [PATCH] avifs: strip to minimal glob wrapper around img2avif Summary stats and progress are now handled by img2avif itself. Co-Authored-By: Claude Opus 4.6 (1M context) --- avifs | 54 ++++-------------------------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/avifs b/avifs index fad98b5..2377a24 100755 --- a/avifs +++ b/avifs @@ -2,17 +2,8 @@ set -euo pipefail setopt nocaseglob -trash=false -positional=() -for arg in "$@"; do - case $arg in - -t|--trash) trash=true ;; - *) positional+=("$arg") ;; - esac -done - -if [[ ${#positional[@]} -gt 0 ]]; then - files=("${positional[@]}") +if [[ ${#@} -gt 0 ]]; then + files=("$@") else extensions=(${(f)"$(globs images -x avif)"}) files=() @@ -20,47 +11,10 @@ else files+=(${~ext}(N)) done fi + if [[ ${#files[@]} -eq 0 ]]; then echo "No image files found." >&2 - echo "Usage: avifs [-t|--trash] [file ...]" >&2 exit 1 fi -orig_size=0 -for f in "${files[@]}"; do - orig_size=$(( orig_size + $(stat -f%z "$f") )) -done - -img2avif --quality 60 --speed 6 "${files[@]}" - -avif_size=0 -converted=0 -for f in "${files[@]}"; do - avif="${f%.*}.avif" - if [[ -f "$avif" ]]; then - avif_size=$(( avif_size + $(stat -f%z "$avif") )) - converted=$(( converted + 1 )) - fi -done -saved=$(( orig_size - avif_size )) -if (( orig_size > 0 )); then - pct=$(( saved * 100 / orig_size )) - if (( orig_size > 1048576 )); then - printf '%d files: %.1fMB → %.1fMB (saved %.1fMB, %d%%)\n' \ - $converted $(( orig_size / 1048576.0 )) $(( avif_size / 1048576.0 )) $(( saved / 1048576.0 )) $pct - else - printf '%d files: %dKB → %dKB (saved %dKB, %d%%)\n' \ - $converted $(( orig_size / 1024 )) $(( avif_size / 1024 )) $(( saved / 1024 )) $pct - fi -fi - -if $trash; then - for f in "${files[@]}"; do - base="${f%.*}" - if [[ -f "${base}.avif" ]]; then - mv "$f" ~/.Trash/ - else - echo "Skipping trash for $f (no .avif output found)" >&2 - fi - done -fi +img2avif "${files[@]}" -- knotmirror 0.0.1