#!/usr/bin/perl

print "Content-type: text/html\n\n";
$curdir=`pwd`;
chomp $curdir;
$curdir=~s:^/home/httpd/html::;
print "<HTML>\n<HEAD>\n<TITLE>Pictures from a Gem Show, Tucson, ";
print "Spring 2000 -- (Low Bandwidth - dialup - Version)";
print "</TITLE>\n</HEAD>\n<BODY>\n";
print "<H1>Pictures from a Gem Show, Tucson, Spring 2000";
print "</H1><P>\n\n";

print "This is the Low Bandwidth (dialup) version of this page for ";
print "people on slow and dialup connections. The version for ";
print "users on High Bandwidth connections is available ";
print "<A HREF=\"index2.cgi\">here.</A><P>\n";

print "These are all the pictures I took, and some of them are not ";
print "quite in focus. In future there will be a page which only has ";
print "the selection of the OK ones. Until then this is the best ";
print "I could do in the time I have right now.<P>\n\n";


mkdir("thumbs",0755) if(! -e "thumbs");

opendir(DIR,".");

print "<TABLE>\n";

$count = 0;

foreach $n (sort readdir DIR) {
	if ($n=~/jpe?g$/ ||
	    $n=~/JPE?G$/) {
		$command = "djpeg $n | pnmscale -xysize 100 100 | " .
			"cjpeg > thumbs/$n";
	} elsif ($n=~/gif$/ ||
	         $n=~/GIF$/) {
		$command = "giftopnm $n | pnmscale -xysize 100 100 | " .
			"pnmtogif > thumbs/$n";
	} else {
		next;
	}

	print "<TR>" if(($count++ % 4) == 0);
	print "<TD><A HREF=\"$n\"><IMG SRC=\"thumbs/$n\"><BR>$n</A>\n";
	
	if ( ! -e "thumbs/$n" ) {
		system $command;
		next;
	}
	
	@ts = stat("thumbs/$n");
	@s = stat($n);
	
	system $command if($ts[9]<$s[9]);
}

print "</TABLE>\n";

closedir DIR;

print "</BODY>\n</HTML>\n";

