#!/usr/bin/perl # # This script will generate an index page and thum jpeg for every *.pnm # file located in the current directory. # # Copyright (c) 2000 Bart Trojanowski # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @files=`ls -1 *.pnm`; $JOPT="-quality 90 -smooth 10 -optimize -progressive"; open(NDX, ">index.html") || die "cannot open index.html for writing\n"; print NDX "Jennifer & Bart Trojanowski\n". "\n". "

Index

\n". ""; for( $i=0; $i<=$#files; $i++ ) { my $f = $files[$i]; chomp $f; ( $f =~ m/^(.*).pnm$/ ) || die "failed to get name from $f\n"; my $name = $1; print "$name...\n"; if ( -z "$name-best.png" ) { system("pnmtopng -compression 9 $f > $name-best.png"); } if ( -z "$name-large.jpeg" ) { system("cjpeg $JOPT -outfile $name-large.jpeg $f"); } if ( -z "$name.jpeg" ) { system("pnmscale -xsize 700 $f | cjpeg $JOPT -outfile $name.jpeg"); } if ( -z "$name-small.jpeg" ) { system("pnmscale -pixels 20000 $f | cjpeg $JOPT -outfile $name-small.jpeg"); } print NDX ""; if( ($i % 4) == 3 ) { print NDX "\n"; } open (PG, ">$name.html") || die "cannot open $name.html for writing\n"; print PG "Jennifer & Bart Trojanowski\n". "\n". "

Image $name

\n". "
$name
".thum($f)."
\n"; $cells=1; if( $i>0 ) { $cells++; print PG ""; } print PG "\n"; if( $i<$#files ) { $cells++; print PG ""; } print PG "
PREV
". thum($files[$i-1]). "
INDEXNEXT
". thum($files[$i+1]). "
\n". "". "\n". "
\n"; close(PG); } print NDX ""; print NDX " "; close(NDX); sub thum { my($f) = @_; chomp $f; ( $f =~ m/^(.*).pnm$/ ) || die "failed to get name from $f\n"; my $name = $1; return "". "\n"; }