]> www.average.org Git - mkgallery.git/blob - mkgallery.pl
26e1729e3d11bddad9967ce68abe190cc9a905f1
[mkgallery.git] / mkgallery.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 # Recursively create image gallery index and slideshow wrappings.
6 # Makes use of modified "slideshow" javascript by Samuel Birch
7 # http://www.phatfusion.net/slideshow/
8
9 # Copyright (c) 2006-2008 Eugene G. Crosser
10
11 #  This software is provided 'as-is', without any express or implied
12 #  warranty.  In no event will the authors be held liable for any damages
13 #  arising from the use of this software.
14 #
15 #  Permission is granted to anyone to use this software for any purpose,
16 #  including commercial applications, and to alter it and redistribute it
17 #  freely, subject to the following restrictions:
18 #
19 #  1. The origin of this software must not be misrepresented; you must not
20 #     claim that you wrote the original software. If you use this software
21 #     in a product, an acknowledgment in the product documentation would be
22 #     appreciated but is not required.
23 #  2. Altered source versions must be plainly marked as such, and must not be
24 #     misrepresented as being the original software.
25 #  3. This notice may not be removed or altered from any source distribution.
26
27 package FsObj;
28
29 use strict;
30 use Carp;
31 use POSIX qw/getcwd strftime/;
32 use CGI qw/:html *table *Tr *td *center *div *Link/;
33 use Image::Info qw/image_info dim/;
34 use Term::ReadLine;
35 use Getopt::Long;
36 use Encode;
37 use encoding 'utf-8';
38 binmode(STDOUT, ":utf8");
39
40 my $haveimagick = eval { require Image::Magick; };
41 { package Image::Magick; }      # to make perl compiler happy
42
43 my $haverssxml = eval { require XML::RSS; };
44 { package XML::RSS; }           # to make perl compiler happy
45
46 my @sizes = (160, 640, 1600);
47
48 ######################################################################
49
50 my $incpath;
51 my $rssobj;
52 my $debug = 0;
53 my $asktitle = 0;
54 my $noasktitle = 0;
55 my $rssfile = "";
56
57 charset("utf-8");
58
59 unless (GetOptions(
60                 'help'=>\&help,
61                 'incpath'=>\$incpath,
62                 'asktitle'=>\$asktitle,
63                 'noasktitle'=>\$noasktitle,
64                 'rssfile=s'=>\$rssfile,
65                 'debug'=>\$debug)) {
66         &help;
67 }
68
69 if ($rssfile && ! $haverssxml) {
70         print STDERR "You need to get XML::RSS from CPAN to use --rssfile\n";
71         exit 1;
72 }
73
74 my $term = new Term::ReadLine "Edit Title";
75
76 FsObj->new(getcwd)->iterate;
77
78 sub help {
79
80         print STDERR <<__END__;
81 usage: $0 [options]
82  --help:        print help message and exit
83  --incpath:     do not try to find .include diretory upstream, use
84                 specified path (absolute or relavive).  Use with causion.
85  --debug:       print a lot of debugging info to stdout as you run
86  --asktitle:    ask to edit album titles even if there are ".title" files
87  --noasktitle:  don't ask to enter album titles even where ".title"
88                 files are absent.  Use partial directory names as titles.
89  --rssfile=...: build RSS feed for newly added "albums", give name of rss file
90 __END__
91
92         exit 1;
93 }
94
95 sub new {
96         my $this = shift;
97         my $class;
98         my $self;
99         if (ref($this)) {
100                 $class = ref($this);
101                 my $parent = $this;
102                 my $name = shift;
103                 my $fullpath = $parent->{-fullpath}.'/'.$name;
104                 $self = {
105                                 -parent=>$parent,
106                                 -root=>$parent->{-root},
107                                 -base=>$name,
108                                 -fullpath=>$fullpath,
109                                 -inc=>'../'.$parent->{-inc},
110                                 -rss=>'../'.$parent->{-rss},
111                         };
112         } else {
113                 $class = $this;
114                 my $root=shift;
115                 $self = {
116                                 -root=>$root,
117                                 -fullpath=>$root,
118                                 -inc=>getinc($root),
119                                 -rss=>getrss($root),
120                         };
121         }
122         bless $self, $class;
123         if ($debug) {
124                 print "new $class:\n";
125                 foreach my $k(keys %$self) {
126                         print "\t$k\t=\t$self->{$k}\n";
127                 }
128         }
129         return $self;
130 }
131
132 sub getinc {
133         my $fullpath=shift;     # this is not a method
134         my $depth=20;           # arbitrary max depth
135
136         if ($incpath) {
137                 return $incpath."/.include";
138         }
139
140         my $inc=".include";
141         while ( ! -d $fullpath."/".$inc ) {
142                 $inc = "../".$inc;
143                 last unless ($depth-- > 0);
144         }
145         if ($depth > 0) {
146                 return $inc.'/';                # prefix with trailing slash
147         } else {
148                 return 'NO-.INCLUDE-IN-PATH/';  # won't work anyway
149         }
150 }
151
152 sub getrss {
153         my $fullpath=shift;     # this is not a method
154         my $depth=20;           # arbitrary max depth
155
156         return "" unless $rssfile;
157
158         my $rss=$rssfile;
159         while ( ! -f $fullpath."/".$rss ) {
160                 $rss = "../".$rss;
161                 last unless ($depth-- > 0);
162         }
163         if ($depth > 0) {
164                 $rssobj->{'file'} = $rss;
165                 $rssobj->{'rss'} = new XML::RSS (version=>2);
166                 $rssobj->{'rss'}->parsefile($rss);
167                 my $itemstodel = @{$rssobj->{'rss'}->{'items'}} - 15;
168                 while ($itemstodel-- > 0) {
169                         pop(@{$rssobj->{'rss'}->{'items'}})
170                 }
171                 $rssobj->{'rss'}->save($rssobj->{'file'});
172                 return $rss;
173         } else {
174                 print STDERR "There is no $rssfile in this or parent ".
175                         "directories, you must create one with mkgalrss.pl\n";
176                 exit 1;
177         }
178 }
179
180 sub iterate {
181         my $self = shift;
182         my $fullpath .= $self->{-fullpath};
183         print "iterate in dir $fullpath\n" if ($debug);
184
185         my $youngest=0;
186         my @rdirlist;
187         my @rimglist;
188         my $D;
189         unless (opendir($D,$fullpath)) {
190                 warn "cannot opendir $fullpath: $!";
191                 return;
192         }
193         while (my $de = readdir($D)) {
194                 next if ($de =~ /^\./);
195                 my $child = $self->new($de);
196                 my @stat = stat($child->{-fullpath});
197                 $youngest = $stat[9] if ($youngest < $stat[9]);
198                 if ($child->isdir) {
199                         push(@rdirlist,$child);
200                 } elsif ($child->isimg) {
201                         push(@rimglist,$child);
202                 }
203         }
204         closedir($D);
205         my @dirlist = sort {$a->{-base} cmp $b->{-base}} @rdirlist;
206         undef @rdirlist; # inplace sorting would be handy here
207         my @imglist = sort {$a->{-base} cmp $b->{-base}} @rimglist;
208         undef @rimglist; # optimize away unsorted versions
209         $self->{-firstimg} = $imglist[0];
210
211         print "Dir: $self->{-fullpath}\n" if ($debug);
212
213 # 1. first of all, fill title for this directory and create hidden subdirs
214
215         $self->initdir;
216
217 # 2. recurse into subdirectories to get their titles filled
218 #    before we start writing out subalbum list
219
220         foreach my $dir(@dirlist) {
221                 $dir->iterate;
222         }
223
224 # 3. iterate through images to build cross-links,
225
226         my $previmg = undef;
227         foreach my $img(@imglist) {
228                 # list-linking must be done before generating
229                 # aux html because aux pages rely on prev/next refs
230                 if ($previmg) {
231                         $previmg->{-nextimg} = $img;
232                         $img->{-previmg} = $previmg;
233                 }
234                 $previmg=$img;
235         }
236
237 # 4. create scaled versions and aux html pages
238
239         foreach my $img(@imglist) {
240                 # scaled versions must be generated before aux html
241                 # and main image index because they both rely on
242                 # refs to scaled images and they may be just original
243                 # images, this is not known before we try scaling.
244                 $img->makescaled;
245                 # finally, make aux html pages
246                 $img->makeaux;
247         }
248
249 # no need to go beyond this point if the directory timestamp did not
250 # change since we built index.html file last time.
251
252         my @istat = stat($self->{-fullpath}.'/index.html');
253         return unless ($youngest > $istat[9]);
254
255 # 5. start building index.html for the directory
256
257         $self->startindex;
258
259 # 6. iterate through subdirectories to build subalbums list
260
261         if (@dirlist) {
262                 $self->startsublist;
263                 foreach my $dir(@dirlist) {
264                         $dir->sub_entry;
265                 }
266                 $self->endsublist;
267         }
268
269 # 7. iterate through images to build thumb list
270
271         if (@imglist) {
272                 $self->startimglist;
273                 foreach my $img(@imglist) {
274                         print "Img: $img->{-fullpath}\n" if ($debug);
275                         $img->img_entry;
276                 }
277                 $self->endimglist;
278         }
279
280 # 8. comlplete building index.html for the directory
281
282         $self->endindex;
283 }
284
285 sub isdir {
286         my $self = shift;
287         return ( -d $self->{-fullpath} );
288 }
289
290 sub isimg {
291         my $self = shift;
292         my $fullpath = $self->{-fullpath};
293         return 0 unless ( -f $fullpath );
294         my $info = image_info($fullpath);
295         if (my $error = $info->{error}) {
296                 if (($error !~ "Unrecognized file format") &&
297                     ($error !~ "Can't read head")) {
298                         warn "File \"$fullpath\": $error\n";
299                 }
300                 return 0;
301         }
302
303         tryapp12($info) unless ($info->{'ExifVersion'});
304
305         $self->{-isimg} = 1;
306         $self->{-info} = $info;
307         return 1;
308 }
309
310 sub tryapp12 {
311         my $info = shift;       # this is not a method
312         my $app12;
313         # dirty hack to take care of Image::Info parser strangeness
314         foreach my $k(keys %$info) {
315                 $app12=substr($k,6).$info->{$k} if ($k =~ /^App12-/);
316         }
317         return unless ($app12); # bad luck
318         my $seenfirstline=0;
319         foreach my $ln(split /[\r\n]+/,$app12) {
320                 $ln =~ s/[[:^print:]\000]/ /g;
321                 unless ($seenfirstline) {
322                         $seenfirstline=1;
323                         $info->{'Make'}=$ln;
324                         next;
325                 }
326                 my ($k,$v)=split /=/,$ln,2;
327                 if ($k eq 'TimeDate') {
328                         $info->{'DateTime'} =
329                                 strftime("%Y:%m:%d %H:%M:%S", localtime($v))
330                                                         unless ($v < 0);
331                 } elsif ($k eq 'Shutter') {
332                         $info->{'ExposureTime'} = '1/'.int(1000000/$v+.5);
333                 } elsif ($k eq 'Flash') {
334                         $info->{'Flash'} = $v?'Flash fired':'Flash did not fire';
335                 } elsif ($k eq 'Type') {
336                         $info->{'Model'} = $v;
337                 } elsif ($k eq 'Version') {
338                         $info->{'Software'} = $v;
339                 } elsif ($k eq 'Fnumber') {
340                         $info->{'FNumber'} = $v;
341                 }
342         }
343 }
344
345 sub initdir {
346         my $self = shift;
347         my $fullpath = $self->{-fullpath};
348         for my $subdir(@sizes, 'html') {
349                 my $tdir=sprintf "%s/.%s",$self->{-fullpath},$subdir;
350                 mkdir($tdir,0755) unless ( -d $tdir );
351         }
352         $self->edittitle;
353 }
354
355 sub edittitle {
356         my $self = shift;
357         my $fullpath = $self->{-fullpath};
358         my $title;
359         my $T;
360         if (open($T,'<'.$fullpath.'/.title')) {
361                 $title = <$T>;
362                 $title =~ s/[\r\n]*$//;
363                 close($T);
364         }
365         if ($asktitle || (!$title && !$noasktitle)) {
366                 my $prompt = $self->{-base};
367                 $prompt = '/' unless ($prompt);
368                 my $OUT = $term->OUT || \*STDOUT;
369                 print $OUT "Enter title for $fullpath\n";
370                 $title = $term->readline($prompt.' >',$title);
371                 $term->addhistory($title) if ($title);
372                 if (open($T,'>'.$fullpath.'/.title')) {
373                         print $T $title,"\n";
374                         close($T);
375                 }
376         }
377         unless ($title) {
378                 $title=substr($fullpath,length($self->{-root}));
379         }
380         $self->{-title}=$title;
381         print "title in $fullpath is $title\n" if ($debug);
382 }
383
384 sub makescaled {
385         my $self = shift;
386         my $fn = $self->{-fullpath};
387         my $name = $self->{-base};
388         my $dn = $self->{-parent}->{-fullpath};
389         my ($w, $h) = dim($self->{-info});
390         my $max = ($w > $h)?$w:$h;
391
392         foreach my $size(@sizes) {
393                 my $nref = '.'.$size.'/'.$name;
394                 my $nfn = $dn.'/'.$nref;
395                 my $factor=$size/$max;
396                 if ($factor >= 1) {
397                         $self->{$size}->{'url'} = $name; # unscaled version
398                         $self->{$size}->{'dim'} = [$w, $h];
399                 } else {
400                         $self->{$size}->{'url'} = $nref;
401                         $self->{$size}->{'dim'} = [$w*$factor, $h*$factor];
402                         if (isnewer($fn,$nfn)) {
403                                 doscaling($fn,$nfn,$factor,$w,$h);
404                         }
405                 }
406         }
407 }
408
409 sub isnewer {
410         my ($fn1,$fn2) = @_;                    # this is not a method
411         my @stat1=stat($fn1);
412         my @stat2=stat($fn2);
413         return (!@stat2 || ($stat1[9] > $stat2[9]));
414         # true if $fn2 is absent or is older than $fn1
415 }
416
417 sub doscaling {
418         my ($src,$dest,$factor,$w,$h) = @_;     # this is not a method
419
420         my $err=1;
421         if ($haveimagick) {
422                 my $im = new Image::Magick;
423                 print "doscaling $src -> $dest by $factor\n" if ($debug);
424                 if ($err = $im->Read($src)) {
425                         warn "ImageMagick: read \"$src\": $err";
426                 } else {
427                         $im->Scale(width=>$w*$factor,height=>$h*$factor);
428                         $err=$im->Write($dest);
429                         warn "ImageMagick: write \"$dest\": $err" if ($err);
430                 }
431                 undef $im;
432         }
433         if ($err) {     # fallback to command-line tools
434                 system("djpeg \"$src\" | pnmscale \"$factor\" | cjpeg >\"$dest\"");
435         }
436 }
437
438 sub makeaux {
439         my $self = shift;
440         my $name = $self->{-base};
441         my $dn = $self->{-parent}->{-fullpath};
442         my $pref = $self->{-previmg}->{-base};
443         my $nref = $self->{-nextimg}->{-base};
444         my $inc = $self->{-inc};
445         my $title = $self->{-info}->{'Comment'};
446         $title = $name unless ($title);
447
448         print "slide: \"$title\": \"$pref\"->\"$name\"->\"$nref\"\n" if ($debug);
449
450         # slideshow
451         for my $refresh('static', 'slide') {
452                 my $fn = sprintf("%s/.html/%s-%s.html",$dn,$name,$refresh);
453                 if (isnewer($self->{-fullpath},$fn)) {
454                         my $imgsrc = '../'.$self->{$sizes[1]};
455                         my $fwdref;
456                         my $bakref;
457                         if ($nref) {
458                                 $fwdref = sprintf("%s-%s.html",$nref,$refresh);
459                         } else {
460                                 $fwdref = '../index.html';
461                         }
462                         if ($pref) {
463                                 $bakref = sprintf("%s-%s.html",$pref,$refresh);
464                         } else {
465                                 $bakref = '../index.html';
466                         }
467                         my $toggleref;
468                         my $toggletext;
469                         if ($refresh eq 'slide') {
470                                 $toggleref=sprintf("%s-static.html",$name);
471                                 $toggletext = 'Stop!';
472                         } else {
473                                 $toggleref=sprintf("%s-slide.html",$name);
474                                 $toggletext = 'Play-&gt;';
475                         }
476                         my $F;
477                         unless (open($F,'>'.$fn)) {
478                                 warn "cannot open \"$fn\": $!";
479                                 next;
480                         }
481                         binmode($F, ":utf8");
482                         if ($refresh eq 'slide') {
483                                 print $F start_html(
484                                         -encoding=>"utf-8",
485                                         -title=>$title,
486                                         -bgcolor=>"#808080",
487                                         -head=>meta({-http_equiv=>'Refresh',
488                                                 -content=>"3; url=$fwdref"}),
489                                         -style=>{-src=>$inc."gallery.css"},
490                                         ),"\n";
491                                                 
492                         } else {
493                                 print $F start_html(-title=>$title,
494                                         -encoding=>"utf-8",
495                                         -bgcolor=>"#808080",
496                                         -style=>{-src=>$inc."gallery.css"},
497                                         ),"\n";
498                         }
499                         print $F start_center,"\n",
500                                 h1($title),"\n",
501                                 start_table({-class=>'navi'}),start_Tr,"\n",
502                                 td(a({-href=>"../index.html"},"Index")),"\n",
503                                 td(a({-href=>$bakref},"&lt;&lt;Prev")),"\n",
504                                 td(a({-href=>$toggleref},$toggletext)),"\n",
505                                 td(a({-href=>$fwdref},"Next&gt;&gt;")),"\n",
506                                 end_Tr,
507                                 end_table,"\n",
508                                 table({-class=>'picframe'},
509                                         Tr(td(img({-src=>$imgsrc})))),"\n",
510                                 end_center,"\n",
511                                 end_html,"\n";
512                         close($F);
513                 }
514         }
515
516         # info html
517         my $fn = sprintf("%s/.html/%s-info.html",$dn,$name);
518         if (isnewer($self->{-fullpath},$fn)) {
519                 my $F;
520                 unless (open($F,'>'.$fn)) {
521                         warn "cannot open \"$fn\": $!";
522                         return;
523                 }
524                 my $imgsrc = sprintf("../.%s/%s",$sizes[0],$name);
525                 print $F start_html(-title=>$title,
526                                 -encoding=>"utf-8",
527                                 -style=>{-src=>$inc."gallery.css"},
528                                 -script=>[
529                                         {-src=>$inc."mootools.js"},
530                                         {-src=>$inc."urlparser.js"},
531                                         {-src=>$inc."infopage.js"},
532                                 ]),"\n",
533                         start_center,"\n",
534                         h1($title),"\n",
535                         table({-class=>'ipage'},
536                                 Tr(td(img({-src=>$imgsrc})),
537                                         td($self->infotable))),
538                         a({-href=>'../index.html',-class=>'conceal'},
539                                 'Index'),"\n",
540                         end_center,"\n",
541                         end_html,"\n";
542                 close($F);
543         }
544 }
545
546 sub startindex {
547         my $self = shift;
548         my $fn = $self->{-fullpath}.'/index.html';
549         my $block = $self->{-fullpath}.'/.noindex';
550         $fn = '/dev/null' if ( -f $block );
551         my $IND;
552         unless (open($IND,'>'.$fn)) {
553                 warn "cannot open $fn: $!";
554                 return;
555         }
556         binmode($IND, ":utf8");
557         $self->{-IND} = $IND;
558
559         my $inc = $self->{-inc};
560         my $title = $self->{-title};
561         my $rsslink="";
562         if ($self->{-rss}) {
563                 $rsslink=Link({-rel=>'alternate',
564                                 -type=>'application/rss+xml',
565                                 -title=>'RSS',
566                                 -href=>$self->{-rss}});
567         }
568         print $IND start_html(-title => $title,
569                         -encoding=>"utf-8",
570                         -head=>$rsslink,
571                         -style=>{-src=>$inc."gallery.css"},
572                         -script=>[
573                                 {-src=>$inc."mootools.js"},
574                                 {-src=>$inc."overlay.js"},
575                                 {-src=>$inc."urlparser.js"},
576                                 {-src=>$inc."multibox.js"},
577                                 {-src=>$inc."slideshow.js"},
578                                 {-src=>$inc."gallery.js"},
579                                 {-code=>"var incPrefix='$inc';"}
580                         ]),
581                 a({-href=>"../index.html"},"UP"),"\n",
582                 start_center,"\n",
583                 h1($title),"\n",
584                 "\n";
585 }
586
587 sub endindex {
588         my $self = shift;
589         my $IND = $self->{-IND};
590
591         print $IND end_center,end_html,"\n";
592
593         close($IND) if ($IND);
594         undef $self->{-IND};
595         if ($rssobj) {
596                 my $rsstitle=sprintf "%s [%d images, %d subalbums]",
597                                 $self->{-title},
598                                 $self->{-numofimgs},
599                                 $self->{-numofsubs};
600                 my $rsslink=$rssobj->{'rss'}->channel('link')."index.html";
601                 $rssobj->{'rss'}->add_item(
602                         title           => $self->{-title},
603                         link            => $rsslink,
604                         description     => $rsstitle,
605                 );
606         }
607 }
608
609 sub startsublist {
610         my $self = shift;
611         my $IND = $self->{-IND};
612
613         print $IND h2("Albums"),"\n",start_table,"\n";
614 }
615
616 sub sub_entry {
617         my $self = shift;
618         my $IND = $self->{-parent}->{-IND};
619         my $name = $self->{-base};
620         my $title = $self->{-title};
621
622         $self->{-parent}->{-numofsubs}++;
623         print $IND Tr(td(a({-href=>$name.'/index.html'},$name)),
624                         td(a({-href=>$name.'/index.html'},$title))),"\n";
625 }
626
627 sub endsublist {
628         my $self = shift;
629         my $IND = $self->{-IND};
630
631         print $IND end_table,"\n",br({-clear=>'all'}),hr,"\n\n";
632 }
633
634 sub startimglist {
635         my $self = shift;
636         my $IND = $self->{-IND};
637         my $first = $self->{-firstimg}->{-base};
638         my $slideref = sprintf(".html/%s-slide.html",$first);
639
640         print $IND h2("Images"),"\n",
641                 a({-href=>$slideref,
642                         -onClick=>"return run_slideshow(-1);"},
643                         'Slideshow'),
644                 start_div({-id=>"slideshowWindow",-class=>"slideshowWindow"}),
645                 div({-id=>"slideshowContainer",
646                         -class=>"slideshowContainer"},""),
647                 start_div({-id=>"slideshowControls",
648                         -class=>"slideshowControls"}),
649                 a({-href=>"#",-onClick=>"show.previous();return false;"},
650                         "Prev"),
651                 a({-href=>"#",-onClick=>"show.play();return false;"},
652                         "Play"),
653                 a({-href=>"#",-onClick=>"show.stop();return false;"},
654                         "Stop"),
655                 a({-href=>"#",-onClick=>"show.next();return false;"},
656                         "Next"),
657                 a({-href=>"#",-onClick=>"stop_slideshow();return false;"},
658                         "Exit"),
659                 end_div,
660                 end_div,
661                 "\n";
662 }
663
664 sub img_entry {
665         my $self = shift;
666         my $IND = $self->{-parent}->{-IND};
667         my $name = $self->{-base};
668         my $title = $self->{-info}->{'Comment'};
669         $title = $name unless ($title);
670         my $thumb = $self->{$sizes[0]}->{'url'};
671         my $info = $self->{-info};
672         my ($w, $h) = dim($info);
673
674         my $i=0+$self->{-parent}->{-numofimgs};
675         $self->{-parent}->{-numofimgs}++;
676
677         print $IND a({-name=>$i}),"\n",
678                 start_table({-class=>'slide'}),start_Tr,start_td,"\n",
679                 div({-class=>'slidetitle',-id=>$name},
680                         a({-href=>".html/$name-info.html?conceal",
681                                 -title=>'Image Info: '.$name,
682                                 -class=>'infoBox'},
683                                 $title)),"\n",
684                 div({-class=>'slideimage',-id=>$name},
685                         a({-href=>".html/$name-static.html",-title=>$title,
686                                 -id=>$name,
687                                 -OnClick=>"return run_slideshow(".$i.");"},
688                                 img({-src=>$thumb}))),"\n",
689                 start_div({-class=>'varimages',-id=>$i});
690         foreach my $sz(@sizes) {
691                 my $src=$self->{$sz}->{'url'};
692                 my $w=$self->{$sz}->{'dim'}->[0];
693                 my $h=$self->{$sz}->{'dim'}->[1];
694                 print $IND a({-href=>$src,-style=>"display: none;",
695                         -class=>($sz == 640)?"slideshowThumbnail":"",
696                         -title=>"Reduced to ".$w."x".$h},
697                         $w."x".$h)," ";
698         }
699         print $IND a({-href=>$name,
700                                 -title=>'Original'},$w."x".$h),
701                 end_div,"\n",
702                 end_td,end_Tr,end_table,"\n";
703 }
704
705 sub endimglist {
706         my $self = shift;
707         my $IND = $self->{-IND};
708
709         print $IND br({-clear=>'all'}),hr,"\n\n";
710 }
711
712 sub infotable {
713         my $self = shift;
714         my $info = $self->{-info};
715         my $msg='';
716
717         my @infokeys=(
718                 'DateTime',
719                 'ExposureTime',
720                 'FNumber',
721                 'Flash',
722                 'ISOSpeedRatings',
723                 'MeteringMode',
724                 'ExposureProgram',
725                 'FocalLength',
726                 'FileSource',
727                 'Make',
728                 'Model',
729                 'Software',
730         );
731         $msg.=start_table({-class=>'infotable'})."\n";
732         foreach my $k(@infokeys) {
733                 $msg.=Tr(td($k.":"),td($info->{$k}))."\n" if ($info->{$k});
734         }
735         $msg.=end_table."\n";
736 }
737