#!/bin/sh
## Run this script from a directory that contains *.jpg images. It will create thumbnails for the images
## and also an index.html file, and an associated css file.
## It will use the folder name for the title of the web page.
## It requires the program 'convert', which is part of the ImageMagick collection.
## It can be found at http://www.imagemagick.org/script/index.php

path=`pwd`
title=`echo "${path##*/}"`
cat >index.html <<EOF
<html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
	<title>$title</title>
	<link rel="stylesheet" href="thumbnailStyle.css" type="text/css" media="screen" title="no title" charset="utf-8" />
</head>
<body>
EOF
ls *.jpg|sed -e 's|\([^ ]*\.jpg\)|<a href=\"\1\"><img src=\"th\1\" alt=\"\1\" class=\"image\" /></a>|g' >>index.html
echo "</body></html>" >>index.html
cat >thumbnailStyle.css <<EOF
img {
	width : 200px;
	height : 200px;
	border-width : 3px;
	border-color : black;
	padding : 2px;
}
EOF
ls *.jpg| xargs -I '{}' convert '{}' -resize 25% th'{}'


