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