in reply to Perl/Tk widget for displaying images and thumbnails
use strict; use English; use Warnings; use Image::Magick; use Image::Magick::Thumbnail; opendir(DIR,$ARGV[0]) || die "Can't open directory: $!\n"; open(FIL,">$ARGV[0]/index.html") || die "Can't write html file: $!\n"; print FIL "<html><body><center><table border=1 cellpadding=3 cellspaci +ng=3><tr>"; mkdir("$ARGV[0]/Thumbnails") unless (-d "$ARGV[0]/Thumbnails"); mkdir("$ARGV[0]/Reduced") unless (-d "$ARGV[0]/Reduced"); my $i=1; foreach (sort grep {/jpg$/i} readdir(DIR)){ if (/Censored/){ print "skipping $_\n"; next; } print "reading $_\n"; my $img = new Image::Magick; $img->Read("$ARGV[0]/$_"); my ($thumb,$x,$y) = Image::Magick::Thumbnail::create($img,640); $thumb->Write("$ARGV[0]/Reduced/$_"); ($thumb,$x,$y) = Image::Magick::Thumbnail::create($img,100); $thumb->Write("$ARGV[0]/Thumbnails/$_"); print FIL "<td><center><a href=\"Reduced/$_\"><img src=\"Thumbnails/ +$_\"></a><br><font face=\"Times New Roman\" size=\"2\"><a href=\"$_\" +>Lrg</a></font></center></td>"; if (!($i++ % 6)) {print FIL "</tr><tr>";} } print FIL "</tr></table></center></body></html>"; close(FIL); closedir(DIR);
|
|---|