tshm
1/31/2014 - 5:51 AM

thumbnail_page_create.pl

#!/usr/bin/perl
$THUMD=".";
#$COMMAND="djpeg | pnmscale -width 250 | cjpeg -quality 80 -optimize";
$COMMAND="djpeg -scale 1/4 | cjpeg -quality 80 -optimize";

&put_header;

mkdir($THUMD,0755);

foreach (@ARGV) {
  warn $i++."\n";
  $photo = $_;
  $_ =~ s/.*\/([^\/]+)\.jpg$/$1\.jpg/;
#   print "$_\n";
  system("cat $photo | $COMMAND > $THUMD/$_");
#  &entry_page($photo, $_);
  &thum_entry($photo, $_, $i);
}

&put_footer;

#------------- thum_entry -------------
sub thum_entry {
  my $photo, $base, $n;
  ($photo, $base, $n) = @_;
  print "<TR>\n" if ($n % 2);
  print <<END
<TD width="300">
  <A HREF="$photo"><IMG SRC="$THUMD/$base"></A>
</TD>
END
    ;
  print "</TR>\n" if !($n % 2);
}

#------------- put_header -------------
sub put_header {
  print <<END
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML LANG="ja-jp">
<HEAD>
<TITLE>T.Shimayama</TITLE>
<META NAME="Author" CONTENT="Shimayama Toshihide">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=iso-2022-jp">
</HEAD>
<BODY TEXT="#FFFFFF" BGCOLOR="#004000" 
LINK="#FFFF00" VLINK="#80FF80" ALINK="#00FF40">
<CENTER>
<TABLE width="600" border="3">
END
}

sub put_footer {
  print <<END
</TABLE>
</BODY>
</HTML>
END
}

#------------- thum_entry -------------
sub entry_page {
  my $photo = $_[0];
  my $name = $_[1];
  open(ENTRY, ">$name.html") || die("cannot open $name.html\n");
  print ENTRY <<END
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML LANG="ja-jp">
<HEAD>
<TITLE>T.Shimayama</TITLE>
<META NAME="Author" CONTENT="Shimayama Toshihide">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=iso-2022-jp">
</HEAD>
<BODY TEXT="#FFFFFF" BGCOLOR="#004000" 
LINK="#FFFF00" VLINK="#80FF80" ALINK="#00FF40">
<CENTER>
<TABLE> 
<TR>
  <TD><IMG SRC="$photo" ALT="photo"><TD>
</TR>
<TR><TD>

</TD></TR>
</TABLE>
<A HREF="test.html">index</A>
</BODY>
</HTML>
END
;
close(ENTRY);
}