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