#!/usr/bin/perl
$PHOTO_DIR="photo";
$O_HEIGHT=100;
sub getsize{
	require "./imgSz.pl";
	
	my $filename=$_[0];
	my $size = -s $filename;

	open(IN, "$filename");
	binmode(IN);
	read(IN, $buf, $size);
	close(IN);

	return &imgSz::szJpeg($buf);

}

sub print_imgtag{
	my $filename="$PHOTO_DIR/$_[0]";
	my $htmlfile=$filename;
	$htmlfile=~s/jpg/html/;
	(my $width,my $height)=&getsize("$filename");

	$width=int ($O_HEIGHT * ($width/$height) );
	$height=$O_HEIGHT;

	print HTML<<"EOL";
        <a href="$htmlfile" onFocus="this.blur()">
          <img src="$filename" width="$width" height="$height" />
        </a>
EOL
}

open(HTML,">./kugephoto.html");
require "./commonhtml.pl";

print HTML &commonhtml::print_head(".");
print HTML "   <div id=\"photowaku\">";


opendir(DIR, './photo');
while (defined($file = readdir(DIR))) {
	if($file =~/jpg$/){
		&print_imgtag("$file");
	}
}
closedir(DIR);

print HTML "    </div>";
print HTML &commonhtml::print_tail(".");
close(HTML);
