#!/bin/bash

# shadowGallery
# Kleines Script, um mal eben schnell ne HTML-Galerie mit Thumbnails zu machen
# Benötigt imagemagick und bash
# Autor: Alexander Feld <shadowing@fsfe.org>
# Lizenz: GNU/GPLv2


THUMBHOEHE=320
THUMBBREITE=240

mkdir thumbs
touch index.html

echo "Titel der Galerie?"
read titel

echo "Lege index.html an.."
echo "<!doctype html>" > index.html
echo "<html>" >> index.html
echo "<head>" >> index.html
echo "	<title>$titel</title>" >> index.html
echo "	<meta charset=\"utf-8\">" >> index.html
echo "	<meta name=\"generator\" content=\"shadowGallery 0.96\">" >> index.html
echo "	<meta name=\"author\" content=\"$(whoami)\">" >> index.html
echo "</head>" >> index.html
echo "<body style=\"font-family: sans-serif; font-size: 11pt\">" >> index.html
echo "	<h1>$titel</h1>" >> index.html
echo "	<div style=\"margin-top: 0px; margin-bottom: 20px;\">" >> index.html
echo "		Um ein Bild in voller Gr&ouml;&szlig;e zu sehen, einfach anklicken!" >> index.html
echo "	</div>" >> index.html
echo "	<div>" >> index.html

for datei in *.jpg *.JPG *.png *.PNG *.gif *.GIF *.xpm *.XPM *.bmp *.BMP
do
	if [ -f "$datei" ]
	then 
		echo "Konvertiere Bild $datei.."
		convert -resize ${THUMBHOEHE}x${THUMBBREITE} "$datei" "thumbs/$datei"
		echo "Füge Bild $datei in die Galerie hinzu.."
		echo "		<a href=\"$datei\"><img src=\"thumbs/$datei\" alt=\"Bild $datei\"></a>" >> index.html
	fi
done

echo "	</div>" >> index.html
echo "</body>" >> index.html
echo "</html>" >> index.html

exit 0