#!/bin/bash
# These three options make it harder to for some part of a script to
# fail without you recognizing it. nounset means that references to an
# unset variable result in an error. This means that you can no longer
# do stuff like this if VAR is potentially unset, because "$VAR" returns
# an error rather than "":
#
# if [ "$VAR" ]; then
#
# fi
#
# To explicitly indicate that you are OK with the variable potentially
# being empty you can instead use ${VAR:-}.

# To avoid errexit for a single command, use "|| true", e.g.,
#    diff foo foobar || true

set -o nounset
set -o pipefail
set -o errexit 
set -o xtrace

for file in raw/*.HEIC; do
  basename=`basename $file`
  magick $file"[0]" -resize 800x800 ${basename%.HEIC}.JPG
done

for file in raw/*.JPG; do
  magick $file -resize 800x800 $file:t
done

echo "<html><body>" > talapuslake.html 
echo "<h3>Hike to Talapus and Ollalie Lake</h3>" >> talapuslake.html
echo "<p>Wednesday, July 30, 2025</p>" >> talapuslake.html
for file in *.JPG; do
  echo \<a href=\'raw/$file\'\>\<img src=\'$file\'\>\</a\> >> talapuslake.html
done
for file in unconvertable/*.HEIC; do
  echo \<a href=\'$file\'\>Non-resizable image\</a\> >> talapuslake.html
done
echo "</body></html>" >> talapuslake.html
