#!/usr/bin/perl

use File::Find;
my $base = "/u11/gile/.html_pages/screens";

sub img_thumbnail {
	my $file = shift;
	if (open(THUMB, "$base/thumb/$file")) {
		close(THUMB);
	} else {
		`/usr/local/bin/convert -scale 120x120 -negate "$base/$file" "$base/thumb/$file"`
	}
}

sub img_size {
	my $file = shift;
	my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat($file);
	my $inter = int(($size / 1024) * 100);
	return $inter / 100;
}

sub img_wanted {
	my $file = $_;
	if ($File::Find::dir eq $base) {
		if ($file =~ /.*\.(gif|jpeg|jpg|png)/) {
			my $size = img_size($file);
			print "<div class=\"imgdisp\"><a href=\"/~gile/screens/$file\"><img src=\"/~gile/screens/thumb/$file\" width=120 height=120 alt=\"Thumbnail of $file\"></a><p>$file<br>($size KB)</p></div>\n";
			img_thumbnail($file);
		}
	}
}

sub iterate_and_print {
	find({"wanted" => \&img_wanted, "follow" => 0 }, ($base));
}


print "Content-type: text/html\r\n\r\n";

#header
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd\">
<html>
	<head>
		<title>The Mute > Random Images From Hell</title>
		<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
		<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"/~gile/wiz.css\">
		<style type=\"text/css\">
		div.imgdisp { float: left; margin: 2px 2px 2px 2px; }
		div.imgdisp p { text-align: center; }
		div.lnkdisp { float: left; margin: 2px 2px 2px 2px; width: 32%; }
		</style>
	</head>
	<body>
		<div id=\"title\">

			A Spiffy Title Goes Here
		</div>
		<div id=\"carrier\">
			<div id=\"container\">
				<div id=\"content\">
					<div id=\"box\">
						<h1>Random Images From Hell</h1>
						<div id=\"sectext\">
<p>This used to be only a section for random screen shots that I made.  Some were from projects I worked on, others from systems being used.  Now, it's just a general collection of images and pictures.</p>
<p>I'm sure some of you out there are asking why I don't using something like Gallery to accomplish this.  Simple, something like that has too much for my needs.  That, and here, I just add images and they automatically show up in the index.  That's all I really need.</p>
						</div>
					</div>\n";

iterate_and_print();

#footer
print "				</div>
			</div>
			<div id=\"nav\">

				<p><a href=\"/~gile/\">Home</a></p>
				<p><a href=\"/~gile/digress/\">Writings</a></p>
				<p><a href=\"/~gile/code/\">Programage</a></p>
				<p><a href=\"/~gile/screens/\">Imaging</a></p>
				<p><a href=\"/~gile/hate/\">Hate</a></p>
			</div>

			<div class=\"clearing\">&nbsp;</div>
		</div>
		<div id=\"right\">
			&copy; 1999-2004 { gile<i>@</i>csh.rit.edu }
		</div>
	</body>
</html>\n";


