Apache-ImgIndex

 view release on metacpan or  search on metacpan

ImgIndex.pm  view on Meta::CPAN

    my($start) = $in{'start'} || 0;

    # remove the base directory from the file path
    (my $dirName = $dir) =~ s/^$root//;

    my($dh) = DirHandle->new($dir) ||
                 $r->log_error("Can't open directory '$dir': $?");

    my(@filelist) = ();
    while( defined($_ = $dh->read) ) {
       next unless(/^(.+)\.(jpg|gif|png)$/i);
       next if(/^\./);
#       next if($1 =~ /thumb/);

       push(@filelist, $_);
    }

    $dh->close;


    # Output page to client

ImgIndex.pm  view on Meta::CPAN

    my($w, $h) = split('x', $gOptions{'thumb-size'});

    ### Thumbnail image table
    output(qq|    <TABLE align="center" bgcolor="#CCCCCC" border="1" width="|, ($w + 25 )* $gOptions{'cols'}, qq|">\n|);

    if(@filelist) {
       my($counter) = 0;
       my @sorted = (sort @filelist);

       for(my $x = $start; $x < @sorted; $x++) {
          $sorted[$x] =~ /^(.+)\.(jpg|gif|png)$/i;
          my($name, $ext) = ($1, $2);

          # set the display name
          my $displayName = '';
          if($gOptions{'show-names'}) {
              ($displayName = $name) =~ s/[_\-]/\s/g;
              $displayName = substr($displayName, 0, 22) . "..." 
                   if(length $displayName >= 22);
          }

ImgIndex.pm  view on Meta::CPAN




# showThumbFile
#
#
sub showThumbFile {
    my $r = shift || return;

    my %mimeType = 
       (jpg => 'image/jpeg', gif => 'image/gif', png => 'image/png');
    my ($name, $path, $ext) = fileparse($r->filename, qr{\.\w*$});
    my($w, $h) = split('x', $gOptions{'thumb-size'});

    $name =~ s/^\.//g;
    $path =~ s/\/$//g;
    $ext =~ s/^\.//g;
 
    (my $imgName = $name) =~ s/-thumb$//i;
    my($thumbName) = "$name.$ext";
    my($Img) = Image::Magick->new();



( run in 1.083 second using v1.01-cache-2.11-cpan-df04353d9ac )