# Warnings, strictures, and modules be here. my $path = '/var/www/guest'; my $wallpath = $path.'/wallpapers'; my @walls = <$wallpath/*>; # Start html, table, and so on in place of this comment. # Need a better way to create a new Tr every 6th image for (my $i = 0; $i < $#walls; $i++) { my $currentpic = $walls[$i]; # Less confusion (my $filename = $currentpic) =~ s/.+\/(.+)/$1/; # Remove path my $thumbnail = "thumbwalls/t_$filename"; thumbnailize($currentpic, $thumbnail) unless -e $thumbnail; my $imgres = getInfo($currentpic); if ($i % 6 == 0) { print $query->start_Tr(); } # Print thumb and info about it if ($i % 6 != 0) { print $query->td( $query->a( {href => $currentpic}, img{src=>$thumbnail, alt=>$filename}), $query->br(), $imgres, ); next; } if ($i % 6 == 0) { print $query->end_Tr(); } } # End some things, do a little cleanup, the whole works here. sub thumbnailize { my ($pic, $thumb) = @_; my $image = Image::Magick->new; $image->Read($pic) or die $!; # I used die thinking it $image->Scale(geometry => '200x200'); # would catch error. $image->Write(filename => $thumb) or die $!; # It didn't. } sub getInfo { my $pic = shift; my $image = Image::Magick->new; print "workz" if -e $pic; # Prints successfully my $err = $image->Read($pic) or die $!; print $err if $err; # Errs successfully my ($xres, $yres) = $image->Get('x-resolution', 'y-resolution'); return "$xres x $yres"; }