# 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