]> git.lizzy.rs Git - dirlistozxa.git/commitdiff
gen-thumbs: only update changed files; use one process per core
authorLizzy Fleckenstein <eliasfleckenstein@web.de>
Sat, 29 Apr 2023 19:22:46 +0000 (21:22 +0200)
committerROllerozxa <rollerozxa@voxelmanip.se>
Sat, 29 Apr 2023 19:34:44 +0000 (21:34 +0200)
gen-thumbs

index 7841b5ff01cd93447664e08e89e5ad61ced91ade..13bffe17e5616ec7aa6c07d8d9ee47da63858f9f 100755 (executable)
@@ -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