diff options
author | Thedro Neely <thedroneely@gmail.com> | 2021-04-11 23:58:16 -0400 |
---|---|---|
committer | Thedro Neely <thedroneely@gmail.com> | 2021-04-11 23:58:16 -0400 |
commit | 153fcdfe01ad4c9862ae301f294152fbf5bdc038 (patch) | |
tree | d62970be4c4b3d372ae63240f539bae44967df9c /bootstrap | |
parent | 822fe77e46f1a8d3e3a4175e43bfb49519c9eb5f (diff) | |
download | thedroneely.com-153fcdfe01ad4c9862ae301f294152fbf5bdc038.tar.gz thedroneely.com-153fcdfe01ad4c9862ae301f294152fbf5bdc038.tar.bz2 thedroneely.com-153fcdfe01ad4c9862ae301f294152fbf5bdc038.zip |
bootstrap/helpers/thumbnails: Group iterations
Diffstat (limited to 'bootstrap')
-rwxr-xr-x | bootstrap/helpers/thumbnails | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/bootstrap/helpers/thumbnails b/bootstrap/helpers/thumbnails index e10d5d3..ec834fe 100755 --- a/bootstrap/helpers/thumbnails +++ b/bootstrap/helpers/thumbnails @@ -15,7 +15,7 @@ gif2webp='gif2webp -min_size -loop_compatibility -metadata none -m 6 -q 80' gifsicle='gifsicle --optimize=3 --crop 270x160 --colors=64 --lossy=100' mogrify_thumbnails='mogrify -path thumbnails -auto-orient -quiet -thumbnail x222' -cd "$directory" || exit 1; +cd "$directory"; mkdir -p thumbnails; for image in *; do @@ -26,13 +26,15 @@ for image in *; do if test "$image" -nt "$timestamp"; then - while [ "$mime" = "image/png" ] || [ "$mime" = "image/jpeg" ]; do - { [ -f "$name.png" ] && [ -f "$name.jpg" ]; } && break; - mogrify -format jpg -quiet "$name.png" || true; - mogrify -format png -quiet "$name.jpg" || true; - done + if [ "$mime" = "image/png" ] || [ "$mime" = "image/jpeg" ]; then + while true; do + { [ -f "$name.png" ] && [ -f "$name.jpg" ]; } && break; + mogrify -format jpg -quiet "$name.png" || true; + mogrify -format png -quiet "$name.jpg" || true; + done - if [ "$mime" = "image/png" ] || [ "$mime" = "image/png" ]; then + size_png=$(wc -c < "$name.png") + size_jpg=$(wc -c < "$name.jpg") $pngquant_images "$name.png" || true; $mogrify_thumbnails "$name.png"; @@ -42,7 +44,7 @@ for image in *; do $mogrify_thumbnails "$name.jpg"; $jpegoptim_thumbnails "thumbnails/$name.jpg"; - if [ "$(wc -c < "$name.png")" -lt "$(wc -c < "$name.jpg")" ]; then + if [ "$size_png" -lt "$size_jpg" ]; then $cwebp_images "$name.png" -o "$name.webp"; $cwebp_thumbnails "thumbnails/$name.png" -o "thumbnails/$name.webp"; else |