From 59b298dc5b6feba812fe9bd2cc9dd6335739dc47 Mon Sep 17 00:00:00 2001 From: thomasba Date: Sun, 8 Dec 2019 16:29:21 +0100 Subject: [PATCH] Added script to generate thumbnails --- Makefile | 3 +++ create-thumbs.sh | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100755 create-thumbs.sh diff --git a/Makefile b/Makefile index 24e12ab..74a15ec 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,9 @@ serve: build: hugo --minify +copy-photos: + bash create-thumbs.sh + clean-build: hugo --cleanDestinationDir --minify diff --git a/create-thumbs.sh b/create-thumbs.sh new file mode 100755 index 0000000..c896acc --- /dev/null +++ b/create-thumbs.sh @@ -0,0 +1,12 @@ +cd static/img +ln -s ../../../thomasba.de-photos/ orig +find orig/ -type f -iname '*.jpg' | while read -r ORIGINAL ; do + FILENAME="photos/${ORIGINAL#orig/}" + THUMB="${FILENAME/%.jpg/-thumb.jpg}" + FOLDER="${FILENAME%$(basename "$FILENAME")}" + echo "Processing \"$ORIGINAL\"..." + [ -d "$FOLDER" ] || mkdir -p "$FOLDER" + [ -f "$THUMB" ] || convert "$ORIGINAL" -strip -quality 0.75 -resize 400x400\> "$THUMB" + [ -f "$FILENAME" ] || convert "$ORIGINAL" -quality 0.80 -resize 2560x2560\> "$FILENAME" +done +rm orig