From alan@agora.rdrop.com Thu Jan  2 10:49 PST 2003
Received: from agora.rdrop.com (agora.rdrop.com [199.26.172.34])
	by dnsman.oce.orst.edu (8.9.2/8.9.2) with ESMTP id KAA05116
	for <toby@coas.oregonstate.edu>; Thu, 2 Jan 2003 10:49:01 -0800 (PST)
Received: from agora.rdrop.com (202@localhost [127.0.0.1])
	by agora.rdrop.com (8.12.5/8.12.2) with ESMTP id h02In5NQ005000
	for <toby@coas.oregonstate.edu>; Thu, 2 Jan 2003 10:49:05 -0800 (PST)
	(envelope-from alan@agora.rdrop.com)
Received: (from alan@localhost)
	by agora.rdrop.com (8.12.5/8.12.2/Submit) id h02In5HF004999
	for toby@coas.oregonstate.edu; Thu, 2 Jan 2003 10:49:05 -0800 (PST)
Date: Thu, 2 Jan 2003 10:49:05 -0800
From: Alan Batie <alan@batie.org>
To: Toby Martin <toby@coas.oregonstate.edu>
Subject: Re: [goosechase]: more thailand
Message-ID: <20030102184905.GB1763@agora.rdrop.com>
References: <200212260504.gBQ540o08509@OCE.ORST.EDU>
Mime-Version: 1.0
Content-Disposition: inline
In-Reply-To: <200212260504.gBQ540o08509@OCE.ORST.EDU>
User-Agent: Mutt/1.5.1i
Content-Type: multipart/mixed; boundary="aM3YZ0Iwxop3KEKx"
Content-Length: 5448
Status: RO


--aM3YZ0Iwxop3KEKx
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Wed, Dec 25, 2002 at 09:04:00PM -0800, Toby Martin wrote:
> Lots more pictures of Thailand at <http://www.peak.org/~toby/thai2002>.
> More temples than you can shke a camera at!

Here's a script to help make it more navigable ;-)
It requires the perl module Image::Info, [cd]jpeg and the pnm tools...

-- 
Alan Batie                   ______    alan.batie.org                Me
alan@batie.org               \    /    www.qrd.org         The Triangle
PGPFP DE 3C 29 17 C0 49 7A    \  /     www.pgpi.com   The Weird Numbers
27 40 A5 3C 37 4A DA 52 B9     \/      spamassassin.taint.org  NO SPAM!

    We've got all the youth we need, how about a fountain of smart?

--aM3YZ0Iwxop3KEKx
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=mkindex

#!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
    if $running_under_some_shell;

use Image::Info qw(image_info dim);

if ($#ARGV < 1) {
    print STDERR "Usage: $0 <title> <pic list>\n";
    exit 1;
}

$title = $ARGV[0];
shift;

open(INDEX, ">index.html") || die "Can't open index.html: $!\n";

print INDEX <<EOF;
<html>
<head>
<title>$title</title>
</head>
<body bgcolor=#FFFFFF>
<center>
<h1>$title</h1>
<table>
<tr>
EOF

$rowcount = 0;
$first = 0;
$last = $#ARGV;
for ($i=$first; $i <= $last; $i++) {
    if ($i != $first) {
	$prev_img = $img;
	$img=$next_img;
    } else {
	$img=`basename $ARGV[$i] .jpg`;
	chop($img);
    }
    if ($i != $last) {
        $next_img=`basename $ARGV[$i+1] .jpg`;
	chop($next_img);
    }

    print "--$img--\n";

    if ( -f "$img.jpg" ) {
	#
	#  Extract image info from the image itself
	#
	$info = image_info("$img.jpg");
	if (my $error = $info->{error}) {
	    die "Can't parse image info for '$img.jpg': $error\n";
	}

	$width = $info->{"width"};
	$height = $info->{"height"};
	$comment = $info->{"Comment"};

	#  Make thumbnail and get size
	system("mkjthumb $img.jpg");

	$info = image_info("$img-thumb.gif");
	$xsize = $info->{"width"};
	$ysize = $info->{"height"};

	#
	#  Print table entry
	#
	print INDEX "<td align=center width=150>\n";
	print INDEX "<a href=\"$img.jpg\"><IMG SRC=\"$img-thumb.gif\" " .
			"width=$xsize height=$ysize></A><BR>\n";
	print INDEX "<font size=-1>\n";
	print INDEX "<a href=\"$img.html\">$width x $height</A><br>\n";

	$need_slash = 0;
	if ($width > 640 || $height > 640) {
	    system("djpeg -pnm < $img.jpg | pnmscale -xysize 640 640 | " .
		"cjpeg > $img-640.jpg");
	    if ($need_slash) {
		print INDEX " / ";
	    }
	    print INDEX "<a href=\"$img-640.html\">640</A>";
	    $need_slash = 1;
	}
	if ($width > 1024 || $height > 1024) {
	    system("djpeg -pnm < $img.jpg | pnmscale -xysize 1024 1024 | " .
		"cjpeg > $img-1024.jpg");
	    if ($need_slash) {
		print INDEX " / ";
	    }
	    print INDEX "<a href=\"$img-1024.html\">1024</A>";
	}

	print INDEX "\n$comment\n<p>\n</font>\n";

	open(IMG_WRAP, ">$img-640.html") ||
	    die "Can't open $img-640.html: $!\n";
	print IMG_WRAP <<EOF;
<html>
<head>
<title>Picture $img</title>
</head>
<body bgcolor=#ffffff>
<center>
<h1>Picture $img</h1>
<img src="$img-640.jpg" width=640 height=480>
</center>
<table width=100% border=0>
<tr>
<td align=left>
EOF
	if ($i != $first) {
	    print IMG_WRAP <<EOF;
<a href="$prev_img-640.html"><img align=left src="$prev_img-thumb.gif"><br>
Previous</a>
EOF
	}

	print IMG_WRAP "</td>\n<td align=right>\n";

	if ($i != $last) {
	    print IMG_WRAP <<EOF;
<a href="$next_img-640.html"><img align=right src="$next_img-thumb.gif"><br>
Next</a>
EOF
	}

	print IMG_WRAP <<EOF;
</td>
</table>
</body>
</html>
EOF
	close(IMG_WRAP);

	if ($width > 640 || $height > 640) {
	    open(IMG_WRAP, ">$img-1024.html") ||
		die "Can't open $img-1024.html: $!\n";
	    print IMG_WRAP <<EOF;
<html>
<head>
<title>Picture $img</title>
</head>
<body bgcolor=#ffffff>
<center>
<h1>Picture $img</h1>
<img src="$img-1024.jpg" width=1024 height=768>
</center>
<table width=100% border=0>
<tr>
<td align=left>
EOF
	    if ($i != $first) {
		print IMG_WRAP <<EOF;
<a href="$prev_img-1024.html"><img align=left src="$prev_img-thumb.gif"><br>
Previous</a>
EOF
	    }

	    print IMG_WRAP "</td>\n<td align=right>\n";

	    if ($i != $last) {
		print IMG_WRAP <<EOF;
<a href="$next_img-1024.html"><img align=right src="$next_img-thumb.gif"><br>
Next</a>
EOF
	    }

	    print IMG_WRAP <<EOF;
</td>
</table>
</body>
</html>
EOF
	    close(IMG_WRAP);
	}

	open(IMG_WRAP, ">$img.html") ||
	    die "Can't open $img.html: $!\n";
	print IMG_WRAP <<EOF;
<html>
<head>
<title>Picture $img</title>
</head>
<body bgcolor=#ffffff>
<center>
<h1>Picture $img</h1>
<img src="$img.jpg" width=$width height=$height>
</center>
<table width=100% border=0>
<tr>
<td align=left>
EOF
	if ($i != $first) {
	    print IMG_WRAP <<EOF;
<a href="$prev_img.html"><img align=left src="$prev_img-thumb.gif"><br>
Previous</a>
EOF
	}

	print IMG_WRAP "</td>\n<td align=right>\n";

	if ($i != $last) {
	    print IMG_WRAP <<EOF;
<a href="$next_img.html"><img align=right src="$next_img-thumb.gif"><br>
Next</a>
EOF
	}

	print IMG_WRAP <<EOF;
</td>
</table>
</body>
</html>
EOF
	close(IMG_WRAP);

	$rowcount++;
	if ( $rowcount >= 5 ) {
	    print INDEX "<TR>";
	    $rowcount = 0;
	}
    } else {
	print STDERR "$img.jpg is not a jpg file\n";
    }
}

print INDEX <<EOF;
</table>
</center>
</body>
</html>
EOF

close(INDEX);
exit 0;

--aM3YZ0Iwxop3KEKx--

