#!/usr/bin/perl use warnings; use strict; use Imager; use Cwd; use File::Basename; #but imager makes it easy opening different file types #watch the width of your picture names #they can widen the table cells if too long umask 0022; my $image = Imager->new(); my $count = 0; my $dir = cwd; my @exts = qw(.jpg .png .gif); # list allowed extensions my @pics= <*.jpg *.gif *.png>; open(HEADER,">header.html"); print HEADER<

Thumbnails for $dir

End_Header close HEADER; open(INDEX,">index.html"); print INDEX< Thumbnails End_Index close INDEX; open(MAIN,">main.html"); print MAIN<

Click thumbnails at left to view

End_Main close MAIN; open(OUT,">left.html"); print OUT< End_Header foreach my $pic (@pics){ $count++; my ($basename,$path,$suffix) = fileparse($pic,@exts); $image->open(file=>$pic) or die $image->errstr(); # my $w = $image->getwidth(); # my $h = $image->getheight(); # Create smaller version my $thumb = $image->scale(xpixels=>100); #$basename.="-t$suffix"; #keeps same ext $basename.='-t.jpg'; #make all thumbs as jpg print "Storing image as: $basename\n"; $thumb->write(file=>$basename, jpegquality=>30) or die $thumb->errstr; # my $tw = $thumb->getwidth(); # my $th = $thumb->getheight(); print OUT<[$pic-thumbnail]
$pic EOTR if($count == 1){print OUT "
"; $count = 0}; } print OUT<
EOHTML close OUT; __END__