From dea803557bd3d3016883cafe89c783d85fcd27c1 Mon Sep 17 00:00:00 2001 From: Lizzy Fleckenstein Date: Sat, 29 Apr 2023 21:22:46 +0200 Subject: [PATCH] gen-thumbs: only update changed files; use one process per core --- gen-thumbs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gen-thumbs b/gen-thumbs index 7841b5f..13bffe1 100755 --- a/gen-thumbs +++ b/gen-thumbs @@ -2,7 +2,13 @@ # Generates thumbs -rm -rf .thumbs/ -mkdir .thumbs - -find \( -iname "*.png" -or -iname "*.jpg" -or -iname "*.jpeg" -or -iname "*.jfif" -or -iname "*.gif" -or -iname "*.webp" \) -exec bash -c 'mogrify -path .thumbs/ -auto-orient -thumbnail 128x128 -quality 90% "{}" &' \; +if [ "$1" != "" ]; then + target_file=.thumbs/$(basename -- "$1") + if [ "$1" -nt "$target_file" ]; then + echo "update $target_file" + mogrify -path .thumbs/ -auto-orient -thumbnail 128x128 -quality 90% "$1" + fi +else + mkdir -p .thumbs + find -not -path "./.thumbs/*" \( -iname "*.png" -or -iname "*.jpg" -or -iname "*.jpeg" -or -iname "*.jfif" -or -iname "*.gif" -or -iname "*.webp" \) | parallel -j$(nproc) "$0" {} +fi -- 2.44.0