<% use Cwd; use Image::Info qw(image_info dim); use Data::Dumper; my $Program = "index.asp"; my $photo_dir = cwd(); my $form = $Request->QueryString(); my $locale = $form->{locale}; my $category = $form->{cat}; my $image = $form->{image}; my %loc_dsc = ( BWI => "Baltimore, MD", DCA => "Washington, DC", DET => "Detroit, MI", HIJ => "Hiroshima, Japan", KYO => "Kyoto, Japan", MDT => "Harrisburg, PA", MRY => "Monterey, CA", NUQ => "Mountain View, CA", OIT => "Oita, Japan", PDX => "Portland, OR", PHL => "Philadelphia, PA", SFO => "San Francisco, CA", TYO => "Tokyo, Japan", ); sub LogAndDie { my ($err_msg) = @_; print STDERR "photos error: $err_msg"; die; } opendir(DIR, "$photo_dir") || LogAndDie("Unable to open $photo_dir: $!\n"); my @locales = grep{ /^\w{3}$/ } readdir(DIR); close(DIR); my @sub_dirs; if (defined $locale) { opendir(SUB, "$photo_dir/$locale") || LogAndDie("Unable to open $photo_dir/$locale: $!\n"); @sub_dirs = grep{ /[^\.|\.\.]/ } readdir(SUB); close(SUB); } my @tnails; my %pics; my $cat_path = "$photo_dir/$locale/$category"; if (defined $locale && defined $category) { opendir(THB, "$cat_path/thumbnails") || LogAndDie("Unable to open $cat_path/thumbnails: $!\n"); @tnails = grep{ /.*\.(jpg|JPG|gif)$/ } readdir(THB); close(THB); # thumbnails and images have the same file names, # they just live in different directories if ($#tnails >= 1) { foreach my $file_name (@tnails) { if (-e "$cat_path/images/$file_name") { my $desc; ($desc = $file_name) =~ s/(_|\.jpg|\.JPG|\.gif)/ /g; my $img_info = image_info("$cat_path/images/$file_name"); if (my $error = $img_info->{error}) { LogAndDie("Unable to parse image info: $error\n"); } # print STDERR Dumper($img_info); my $comment = $img_info->{UserComment}; my $date = $img_info->{DateTimeDigitized}; my $flash = $img_info->{Flash}; my $exposure_mode = $img_info->{ExposureMode}; my $resolution = $img_info->{resolution}; my $camera = $img_info->{Model}; my ($width, $height) = dim($img_info); $pics{$file_name} = { nail => "$locale/$category/thumbnails/$file_name", image => "$locale/$category/images/$file_name", file => "$file_name", desc => "$desc", comment => "$comment", date => "$date", flash => "$flash", exp => "$exposure_mode", res => "$resolution", width => "$width", height => "$height", }; } } } else { print STDERR "No thumbnails according to my computer logic!\n"; } } %> Photos
<% foreach my $loc (sort @locales) { %> <%= $loc %> <% } %>
<% if (defined $locale) { %>
<% foreach my $sub (@sub_dirs) { my $cat_name; ($cat_name = $sub) =~ s/_/ /g; %> <%= $cat_name %> <% } %>
<% } %>
:: Back to Barrel :: <% if (defined $category) { %>
<% foreach my $pic (sort keys %pics) { %> <%= $pics{$pic}->{desc} %> <% } %>
<% } %> <% if (defined $image) { %>
<%= $pics{$image}->{desc} %>

<%= $pics{$image}->{desc}%>

<%= $pics{$image}->{height} %>x<%= $pics{$image}->{width} %> taken <%= $pics{$image}->{date} %> <%= $pics{$image}->{flash} =~ /Flash fired/ ? 'with flash' : '' %> at <%= $pics{$image}->{res} %> using <%= $pics{$image}->{exp} %>

<% } %>