#!/usr/bin/perl # Author: Peter R. Wood, http://prwdot.org/ use strict; use CGI; use Image::Info; my $q = new CGI; my $root = ""; my $web_root = ""; print $q->header(); my $location = $q->param('location') || "/"; my $prev = $q->param('prev'); my $curr_dir = "$root/$location"; opendir( CURR, "$curr_dir" ) || die "Couldn't open $curr_dir: $!"; my @files = grep( !/^\.+/, readdir(CURR) ); my $table = ""; my $directories = ""; my $header_row = $q->Tr( { -bgcolor => 'lightblue' }, $q->th( [ "Thumbnail", "View", "Size", "Captured", "Shutter Speed", "Aperture", "Flash", "Scene", "Metering", "White Balance", "Custom Render" ] ) ); foreach my $file (@files) { if ( !-f "$curr_dir/$file" ) { $directories .= $q->li( $q->a( { -href => "location=$location/$file&prev=$location" }, $file ) ); } elsif ( $file !~ /_t\./ ) { my $info = Image::Info::image_info("$curr_dir/$file"); my $thumb_link = ""; my $thumb_file = $file; $thumb_file =~ s/(.+)\.(.+)/$1_t\.$2/g; if ( -e "$curr_dir/$thumb_file" ) { $thumb_link = $q->img( { -src => "$web_root/$location/$thumb_file" } ); } $table .= $q->Tr( $q->td( [ $thumb_link, $q->a( { -href => "$web_root/$location/$file" }, $file ), $info->{'width'} . "W x " . $info->{'height'} . "H", $info->{'DateTimeDigitized'}, $info->{'ExposureTime'}, "f/" . eval( $info->{'FNumber'} ), $info->{'Flash'}, $info->{'SceneCaptureType'}, $info->{'MeteringMode'}, $info->{'WhiteBalance'}, $info->{'CustomRendered'} ] ) ); } } if ($directories) { $directories = $q->ul($directories); } if ($table) { $table = $q->table( { -bgcolor => 'lightgrey', -cellpadding => '2', -cellspacing => '2', -border => '1' }, $header_row . $table ); } my $prev_link = ""; if ($prev) { $prev_link = $q->p( $q->a( { -href => "?location=$prev" }, 'Back Up' ) ); } my $page = $q->start_html( { -title => "Browsing $location" } ) . $q->h1("Browsing $location") . $prev_link . $directories . $table . $q->end_html; print $page;