Skip to content

Commit

Permalink
Make gen_thumbnails.sh more robust
Browse files Browse the repository at this point in the history
Also use magick instead of convert whihc is deprecated.
  • Loading branch information
florianfesti committed Dec 27, 2024
1 parent 819fecb commit d8b5e45
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/gen_thumbnails.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ THUMB_HEIGHT=10000 # height: auto;

thumbnail() {
echo "convert \"$1\" -thumbnail ${THUMB_WIDTH}x${THUMB_HEIGHT} \"${1%.*}-thumb.jpg\""
convert "$1" -thumbnail ${THUMB_WIDTH}x${THUMB_HEIGHT} "${1%.*}-thumb.jpg"
magick "$1" -thumbnail ${THUMB_WIDTH}x${THUMB_HEIGHT} "${1%.*}-thumb.jpg"
git add "$1" "${1%.*}-thumb.jpg" "$STATIC_DIR"samples.sha256
}

[ ! -f "$STATIC_DIR"samples.sha256 ] && touch "$STATIC_DIR"samples.sha256

find "$STATIC_DIR" -name '*.jpg' ! -name '*-thumb.jpg' -type f | while read -r f
do
f_=$(echo "$f" | sed -E -e 's@([.])@\\\1@g')
f_=$(echo "$f" | sed -E -e 's@([.])@\\\1@g')
checksum=$(grep "$f_" "$STATIC_DIR"samples.sha256 || true)
if [ -n "$checksum" ]
then
echo "$checksum" | sha256sum -c --status || {
echo "File $f changed"
sed -i "/$f_/ c\\
sed -i "\\@$f_@ c\\
$(sha256sum "$f")
" "$STATIC_DIR"samples.sha256
thumbnail "$f"
Expand Down

0 comments on commit d8b5e45

Please sign in to comment.