[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: show total size saved after encoding

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

+26
+26
avifs
··· 26 26 exit 1 27 27 fi 28 28 29 + orig_size=0 30 + for f in "${files[@]}"; do 31 + orig_size=$(( orig_size + $(stat -f%z "$f") )) 32 + done 33 + 29 34 printf '%s\0' "${files[@]}" | parallel -0 'avifenc -j 1 --speed 6 {} {.}.avif' 35 + 36 + avif_size=0 37 + converted=0 38 + for f in "${files[@]}"; do 39 + avif="${f%.*}.avif" 40 + if [[ -f "$avif" ]]; then 41 + avif_size=$(( avif_size + $(stat -f%z "$avif") )) 42 + (( converted++ )) 43 + fi 44 + done 45 + saved=$(( orig_size - avif_size )) 46 + if (( orig_size > 0 )); then 47 + pct=$(( saved * 100 / orig_size )) 48 + if (( orig_size > 1048576 )); then 49 + printf '%d files: %.1fMB → %.1fMB (saved %.1fMB, %d%%)\n' \ 50 + $converted $(( orig_size / 1048576.0 )) $(( avif_size / 1048576.0 )) $(( saved / 1048576.0 )) $pct 51 + else 52 + printf '%d files: %dKB → %dKB (saved %dKB, %d%%)\n' \ 53 + $converted $(( orig_size / 1024 )) $(( avif_size / 1024 )) $(( saved / 1024 )) $pct 54 + fi 55 + fi 30 56 31 57 if $trash; then 32 58 for f in "${files[@]}"; do