Files
sabbatical.ipng.nl/mkgallery.sh

46 lines
942 B
Bash
Executable File

#!/usr/bin/env bash
# set -x
BASE=~pim/Public/sabbatical.ipng.nl/static/img
[ -d $BASE ] || {
echo "Cannot find \$BASE directory"; exit 1
}
ARR=()
while [ $# -gt 0 ]; do
FN=$1; shift
BN=$(basename $FN)
echo -n Processing $FN
DATE=$(identify -format '%[EXIF:*]' $FN | awk -F= '/exif:DateTime=/ { sub(" .*","",$2); gsub(":","-",$2); print $2 }')
if [[ $DATE == *"2024-"* ]]; then
mkdir -p $BASE/fullsize/$DATE $BASE/thumbnails/$DATE
magick $FN -resize 300x $BASE/thumbnails/$DATE/$BN
cp $FN $BASE/fullsize/$DATE/$BN
ARR+=($DATE/$BN)
echo "... done!"
else
echo "... skipping, no date found"
fi
done
# Output the gallery for inclusion in the article
set +x
cat << EOF
## Pictures of the Day
{{< gallery-category >}}
EOF
for pic in "${ARR[@]}"
do
echo " {{< gallery-photo fn=\"$pic\" caption=\"\" >}}"
done
cat << EOF
{{< /gallery-category >}}
{{< gallery-modal >}}
{{< gallery-script >}}
EOF