geocation.com/build.sh
2022-04-10 12:57:02 -04:00

35 lines
946 B
Bash
Executable File

#!/bin/bash
set -euxo pipefail
cd "${BASH_SOURCE[0]%/*}"
rm -rf build
mkdir build
(
echo "Building HTML"
shopt -s extglob
while IFS= read -r -d '' || [[ "${REPLY}" ]]; do
cat header.html "${REPLY}" footer.html >"./build/${REPLY}"
done < <(find . -maxdepth 1 -type f -name '*.html' -not -name 'header.html' -and -not -name 'footer.html' -print0)
)
cp -vr css/ images/ build/
render_image() {
local SIZE="${1}" FILENAME="${2}" EXTRA_OPTIONS=(-auto-orient)
shift 2
if [[ "${1}" == "--square" ]]; then
EXTRA_OPTIONS+=(-background none -gravity center -extent "${SIZE}")
fi
convert -resize "${SIZE}^" "${EXTRA_OPTIONS[@]}" "orig/${FILENAME}" "build/images/${FILENAME}"
}
render_image 200x200 "5._Elementary_GLOBE_Climate_Book_Cover.jpg" --square
render_image 200x200 "Diane_Student_Scammon_Bay.png" --square
echo "Stripping metadata"
exiftool -overwrite_original -all= -- build/images/*.*
echo "Website built $(date)"