X-Git-Url: http://www.average.org/gitweb/?p=mkgallery.git;a=blobdiff_plain;f=mkgallery.pl;h=822cd49845d1f900e40ef0c54d0911df1cdfc936;hp=a6252e6403d4c9c7d50e3b5ab61bc02e66189d10;hb=2b396eee650aa66eeffb38a2fefdec240741484f;hpb=96a2650cf7261e7427592a2f635c87f4efe5fd92 diff --git a/mkgallery.pl b/mkgallery.pl index a6252e6..822cd49 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -28,7 +28,7 @@ package FsObj; use strict; use Carp; -use POSIX qw/getcwd/; +use POSIX qw/getcwd strftime/; use CGI qw/:html *table *Tr *center *div/; use Image::Info qw/image_info dim/; use Term::ReadLine; @@ -216,11 +216,49 @@ sub isimg { } return 0; } + + tryapp12($info) unless ($info->{'ExifVersion'}); + $self->{-isimg} = 1; $self->{-info} = $info; return 1; } +sub tryapp12 { + my $info = shift; # this is not a method + my $app12; + # dirty hack to take care of Image::Info parser strangeness + foreach my $k(keys %$info) { + $app12=substr($k,6).$info->{$k} if ($k =~ /^App12-/); + } + return unless ($app12); # bad luck + my $seenfirstline=0; + foreach my $ln(split /[\r\n]+/,$app12) { + $ln =~ s/[[:^print:]\000]/ /g; + unless ($seenfirstline) { + $seenfirstline=1; + $info->{'Make'}=$ln; + next; + } + my ($k,$v)=split /=/,$ln,2; + if ($k eq 'TimeDate') { + $info->{'DateTime'} = + strftime("%Y:%m:%d %H:%M:%S", localtime($v)) + unless ($v < 0); + } elsif ($k eq 'Shutter') { + $info->{'ExposureTime'} = '1/'.int(1000000/$v+.5); + } elsif ($k eq 'Flash') { + $info->{'Flash'} = $v?'Flash fired':'Flash did not fire'; + } elsif ($k eq 'Type') { + $info->{'Model'} = $v; + } elsif ($k eq 'Version') { + $info->{'Software'} = $v; + } elsif ($k eq 'Fnumber') { + $info->{'FNumber'} = $v; + } + } +} + sub initdir { my $self = shift; my $fullpath = $self->{-fullpath}; @@ -402,6 +440,8 @@ sub makeaux { sub startindex { my $self = shift; my $fn = $self->{-fullpath}.'/index.html'; + my $block = $self->{-fullpath}.'/.noindex'; + $fn = '/dev/null' if ( -f $block ); my $IND; unless (open($IND,'>'.$fn)) { warn "cannot open $fn: $!"; @@ -491,13 +531,13 @@ sub img_entry { end_div,"\n"; print $IND table({-class=>'slide'},Tr(td( - a({-href=>".html/$name-info.html", + a({-href=>".html/$name-info.html",-title=>'Image Info', -onClick=>"return showIbox('$name');"},$title), br, a({-href=>$medium,-rel=>"lightbox",-title=>$title}, img({-src=>$thumb})), br, - a({-href=>$name},"($w x $h)"), + a({-href=>$name,-title=>'Original Image'},"($w x $h)"), br))),"\n"; }