]> www.average.org Git - mkgallery.git/blob - mkgallery.pl
1132a7f0c292868763104fd7e77d363714948ca9
[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-2013 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 HTTP::Date;
33 use CGI qw/:html *table *Tr *td *center *div *Link/;
34 use Image::Info qw/image_info dim/;
35 use Term::ReadLine;
36 use Getopt::Long;
37 use Encode;
38 use UUID;
39 #use encoding 'utf-8';
40 binmode(STDOUT, ":utf8");
41
42 my $haveimagick = eval { require Image::Magick; };
43 { package Image::Magick; }      # to make perl compiler happy
44
45 my $havegeoloc = eval { require Image::ExifTool::Location; };
46 { package Image::ExifTool::Location; }  # to make perl compiler happy
47
48 my @sizes = (160, 640, 1600);
49 my $incdir = ".gallery2";
50
51 ######################################################################
52
53 my $incpath;
54 my $debug = 0;
55 my $asktitle = 0;
56 my $noasktitle = 0;
57
58 charset("utf-8");
59
60 unless (GetOptions(
61                 'help'=>\&help,
62                 'incpath'=>\$incpath,
63                 'asktitle'=>\$asktitle,
64                 'noasktitle'=>\$noasktitle,
65                 'debug'=>\$debug)) {
66         &help;
67 }
68
69 my $term = new Term::ReadLine "Edit Title";
70
71 FsObj->new(getcwd)->iterate;
72
73 sub help {
74
75         print STDERR <<__END__;
76 usage: $0 [options]
77  --help:        print help message and exit
78  --incpath:     do not try to find .gallery2 directory upstream, use
79                 specified path (absolute or relavive).  Use with causion.
80  --debug:       print a lot of debugging info to stdout as you run
81  --asktitle:    ask to edit album titles even if there are ".title" files
82  --noasktitle:  don't ask to enter album titles even where ".title"
83                 files are absent.  Use partial directory names as titles.
84 __END__
85
86         exit 1;
87 }
88
89 sub new {
90         my $this = shift;
91         my $class;
92         my $self;
93         if (ref($this)) {
94                 $class = ref($this);
95                 my $parent = $this;
96                 my $name = shift;
97                 $self = {
98                                 -parent=>$parent,
99                                 -root=>$parent->{-root},
100                                 -toppath=>$parent->{-toppath},
101                                 -depth=>$parent->{-depth}+1,
102                                 -base=>$name,
103                                 -fullpath=>$parent->{-fullpath}.'/'.$name,
104                                 -relpath=>$parent->{-relpath}.$name.'/',
105                                 -inc=>'../'.$parent->{-inc},
106                         };
107         } else {
108                 $class = $this;
109                 my $root=shift;
110                 $self = {
111                                 -root=>$root,
112                                 -fullpath=>$root,
113                         };
114                 # fill in -inc, -relpath
115                 initpaths($self); # we are not blessed yet, so cheat.
116         }
117         bless $self, $class;
118         if ($debug) {
119                 print "new $class:\n";
120                 foreach my $k(keys %$self) {
121                         print "\t$k\t=\t$self->{$k}\n";
122                 }
123         }
124         return $self;
125 }
126
127 sub initpaths {
128         my $self=shift;         # this is not a method but we cheat
129         my $depth=20;           # arbitrary max depth
130         my $fullpath=$self->{-fullpath};
131         my $inc;
132         my $relpath;
133
134         if ($incpath) {
135                 $inc = $incpath;
136                 $inc .= '/' unless ($inc =~ m%/$%);
137         } else {
138                 $inc="";
139                 while ( ! -d $fullpath."/".$inc."/".$incdir ) {
140                         $inc = "../".$inc;
141                         last unless ($depth-- > 0);
142                 }
143         }
144         if ($depth > 0) {
145                 $self->{-inc} = $inc;
146                 my $dp=0;
147                 my $pos;
148                 for ($pos=index($inc,'/');$pos>=0;
149                                         $pos=index($inc,'/',$pos+1)) {
150                         $dp++;
151                 }
152                 $self->{-depth} = $dp;
153                 for ($pos=length($fullpath);$dp>0 && $pos>0;
154                                         $pos=rindex($fullpath,'/',$pos-1)) {
155                         $dp--;
156                 }
157                 my $relpath = substr($fullpath,$pos);
158                 $relpath =~ s%^/%%;
159                 $relpath .= '/' if ($relpath);
160                 $self->{-relpath} = $relpath;
161                 $self->{-toppath} = substr($fullpath,0,$pos);
162                 #print "rel=$relpath, top=$self->{-toppath}, inc=$inc\n";
163         } else {
164                 $self->{-inc} = 'NO-.INCLUDE-IN-PATH/'; # won't work anyway
165                 $self->{-relpath} = '';
166                 $self->{-depth} = 0;
167         }
168 }
169
170 sub iterate {
171         my $self = shift;
172         my $fullpath .= $self->{-fullpath};
173         print "iterate in dir $fullpath\n" if ($debug);
174
175         my $youngest=0;
176         my @rdirlist;
177         my @rimglist;
178         my $D;
179         unless (opendir($D,$fullpath)) {
180                 warn "cannot opendir $fullpath: $!";
181                 return;
182         }
183         while (my $de = readdir($D)) {
184                 next if ($de =~ /^\./);
185                 my $child = $self->new($de);
186                 my @stat = stat($child->{-fullpath});
187                 $youngest = $stat[9] if ($youngest < $stat[9]);
188                 if ($child->isdir) {
189                         push(@rdirlist,$child);
190                 } elsif ($child->isimg) {
191                         push(@rimglist,$child);
192                 }
193         }
194         closedir($D);
195         my @dirlist = sort {$a->{-base} cmp $b->{-base}} @rdirlist;
196         undef @rdirlist; # inplace sorting would be handy here
197         my @imglist = sort {$a->{-base} cmp $b->{-base}} @rimglist;
198         undef @rimglist; # optimize away unsorted versions
199         $self->{-firstimg} = $imglist[0];
200
201         print "Dir: $self->{-fullpath}\n" if ($debug);
202
203 # 1. first of all, fill title for this directory and create hidden subdirs
204
205         $self->initdir;
206
207 # 2. recurse into subdirectories to get their titles filled
208 #    before we start writing out subalbum list
209
210         foreach my $dir(@dirlist) {
211                 $dir->iterate;
212         }
213
214 # 3. iterate through images to build cross-links,
215
216         my $previmg = undef;
217         foreach my $img(@imglist) {
218                 # list-linking must be done before generating
219                 # aux html because aux pages rely on prev/next refs
220                 if ($previmg) {
221                         $previmg->{-nextimg} = $img;
222                         $img->{-previmg} = $previmg;
223                 }
224                 $previmg=$img;
225         }
226
227 # 4. create scaled versions and aux html pages
228
229         foreach my $img(@imglist) {
230                 # scaled versions must be generated before aux html
231                 # and main image index because they both rely on
232                 # refs to scaled images and they may be just original
233                 # images, this is not known before we try scaling.
234                 $img->makescaled;
235                 # finally, make aux html pages
236                 $img->makeaux;
237         }
238
239 # no need to go beyond this point if the directory timestamp did not
240 # change since we built index.html file last time.
241
242         my @istat = stat($self->{-fullpath}.'/index.html');
243         return unless ($youngest > $istat[9]);
244
245 # 5. start building index.html for the directory
246
247         $self->startindex;
248
249 # 6. iterate through subdirectories to build subalbums list
250
251         if (@dirlist) {
252                 $self->startsublist;
253                 foreach my $dir(@dirlist) {
254                         $dir->sub_entry;
255                 }
256                 $self->endsublist;
257         }
258
259 # 7. iterate through images to build thumb list
260
261         if (@imglist) {
262                 $self->startimglist;
263                 foreach my $img(@imglist) {
264                         print "Img: $img->{-fullpath}\n" if ($debug);
265                         $img->img_entry;
266                 }
267                 $self->endimglist;
268         }
269
270 # 8. comlplete building index.html for the directory
271
272         $self->endindex;
273 }
274
275 sub isdir {
276         my $self = shift;
277         return ( -d $self->{-fullpath} );
278 }
279
280 sub isimg {
281         my $self = shift;
282         my $fullpath = $self->{-fullpath};
283         return 0 unless ( -f $fullpath );
284
285         if ($havegeoloc) {
286                 my $exif = new Image::ExifTool;
287                 $exif->ExtractInfo($fullpath);
288                 my ($la,$lo) = $exif->GetLocation();
289                 if ($la && $lo) {
290                         $self->{-geoloc} = [$la,$lo];
291                 }
292         }
293
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 $titleimage;
360         my $T;
361         my $TI;
362         if (open($T,'<'.$fullpath.'/.title')) {
363                 binmode($T, ":utf8");
364                 $title = <$T>;
365                 $title =~ s/[\r\n]*$//;
366                 close($T);
367         }
368         if ($asktitle || (!$title && !$noasktitle)) {
369                 my $prompt = $self->{-relpath};
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=$self->{-relpath};
382         }
383         $self->{-title}=$title;
384         if (open($TI,'<'.$fullpath.'/.titleimage')) {
385                 binmode($TI, ":utf8");
386                 $titleimage = <$TI>;
387                 $titleimage =~ s/[\r\n]*$//;
388                 close($TI);
389                 #print STDERR "found title image \"",$titleimage,"\"\n";
390                 $self->{-titleimage}=$titleimage;
391         }
392         print "title in $fullpath is $title\n" if ($debug);
393 }
394
395 sub makescaled {
396         my $self = shift;
397         my $fn = $self->{-fullpath};
398         my $name = $self->{-base};
399         my $dn = $self->{-parent}->{-fullpath};
400         my ($w, $h) = dim($self->{-info});
401         my $max = ($w > $h)?$w:$h;
402
403         foreach my $size(@sizes) {
404                 my $nref = '.'.$size.'/'.$name;
405                 my $nfn = $dn.'/'.$nref;
406                 my $factor=$size/$max;
407                 if ($factor >= 1) {
408                         $self->{$size}->{'url'} = $name; # unscaled version
409                         $self->{$size}->{'dim'} = [$w, $h];
410                 } else {
411                         $self->{$size}->{'url'} = $nref;
412                         $self->{$size}->{'dim'} = [int($w*$factor+.5),
413                                                         int($h*$factor+.5)];
414                         if (isnewer($fn,$nfn)) {
415                                 doscaling($fn,$nfn,$factor,$w,$h);
416                         }
417                 }
418         }
419 }
420
421 sub isnewer {
422         my ($fn1,$fn2) = @_;                    # this is not a method
423         my @stat1=stat($fn1);
424         my @stat2=stat($fn2);
425         return (!@stat2 || ($stat1[9] > $stat2[9]));
426         # true if $fn2 is absent or is older than $fn1
427 }
428
429 sub doscaling {
430         my ($src,$dest,$factor,$w,$h) = @_;     # this is not a method
431
432         my $err=1;
433         if ($haveimagick) {
434                 my $im = new Image::Magick;
435                 print "doscaling $src -> $dest by $factor\n" if ($debug);
436                 if ($err = $im->Read($src)) {
437                         warn "ImageMagick: read \"$src\": $err";
438                 } else {
439                         $im->Scale(width=>$w*$factor,height=>$h*$factor);
440                         $err=$im->Write($dest);
441                         warn "ImageMagick: write \"$dest\": $err" if ($err);
442                 }
443                 undef $im;
444         }
445         if ($err) {     # fallback to command-line tools
446                 system("djpeg \"$src\" | pnmscale \"$factor\" | cjpeg >\"$dest\"");
447         }
448 }
449
450 sub makeaux {
451         my $self = shift;
452         my $name = $self->{-base};
453         my $dn = $self->{-parent}->{-fullpath};
454         my $pref = $self->{-previmg}->{-base};
455         my $nref = $self->{-nextimg}->{-base};
456         my $inc = $self->{-inc}.$incdir.'/';
457         my $title = $self->{-info}->{'Comment'};
458         $title = $name unless ($title);
459
460         print "slide: \"$title\": \"$pref\"->\"$name\"->\"$nref\"\n" if ($debug);
461
462         # slideshow
463         for my $refresh('static', 'slide') {
464                 my $fn = sprintf("%s/.html/%s-%s.html",$dn,$name,$refresh);
465                 if (isnewer($self->{-fullpath},$fn)) {
466                         my $imgsrc = '../'.$self->{$sizes[1]}->{'url'};
467                         my $fwdref;
468                         my $bakref;
469                         if ($nref) {
470                                 $fwdref = sprintf("%s-%s.html",$nref,$refresh);
471                         } else {
472                                 $fwdref = '../index.html';
473                         }
474                         if ($pref) {
475                                 $bakref = sprintf("%s-%s.html",$pref,$refresh);
476                         } else {
477                                 $bakref = '../index.html';
478                         }
479                         my $toggleref;
480                         my $toggletext;
481                         if ($refresh eq 'slide') {
482                                 $toggleref=sprintf("%s-static.html",$name);
483                                 $toggletext = 'Stop!';
484                         } else {
485                                 $toggleref=sprintf("%s-slide.html",$name);
486                                 $toggletext = 'Play-&gt;';
487                         }
488                         my $F;
489                         unless (open($F,'>'.$fn)) {
490                                 warn "cannot open \"$fn\": $!";
491                                 next;
492                         }
493                         binmode($F, ":utf8");
494                         if ($refresh eq 'slide') {
495                                 print $F start_html(
496                                         -encoding=>"utf-8",
497                                         -title=>$title,
498                                         -bgcolor=>"#808080",
499                                         -head=>meta({-http_equiv=>'Refresh',
500                                                 -content=>"3; url=$fwdref"}),
501                                         -style=>{-src=>$inc."gallery.css"},
502                                         ),"\n",
503                                         comment("Created by ".$version),"\n";
504                                                 
505                         } else {
506                                 print $F start_html(-title=>$title,
507                                         -encoding=>"utf-8",
508                                         -bgcolor=>"#808080",
509                                         -style=>{-src=>$inc."gallery.css"},
510                                         ),"\n",
511                                         comment("Created by ".$version),"\n";
512                         }
513                         print $F start_table({-class=>'navi'}),start_Tr,"\n",
514                                 td(a({-href=>"../index.html"},"Index")),"\n",
515                                 td(a({-href=>$bakref},"&lt;&lt;Prev")),"\n",
516                                 td(a({-href=>$toggleref},$toggletext)),"\n",
517                                 td(a({-href=>$fwdref},"Next&gt;&gt;")),"\n",
518                                 td({-class=>'title'},$title),"\n",
519                                 end_Tr,
520                                 end_table,"\n",
521                                 center(table({-class=>'picframe'},
522                                         Tr(td(img({-src=>$imgsrc,
523                                                    -class=>'standalone',
524                                                    -alt=>$title}))))),"\n",
525                                 end_html,"\n";
526                         close($F);
527                 }
528         }
529
530         # info html
531         my $fn = sprintf("%s/.html/%s-info.html",$dn,$name);
532         if (isnewer($self->{-fullpath},$fn)) {
533                 my $F;
534                 unless (open($F,'>'.$fn)) {
535                         warn "cannot open \"$fn\": $!";
536                         return;
537                 }
538                 binmode($F, ":utf8");
539                 my $imgsrc = sprintf("../.%s/%s",$sizes[0],$name);
540                 print $F start_html(-title=>$title,
541                                 -encoding=>"utf-8",
542                                 -style=>{-src=>$inc."gallery.css"},
543                                 -script=>[
544                                         {-src=>$inc."mootools.js"},
545                                         {-src=>$inc."urlparser.js"},
546                                         {-src=>$inc."infopage.js"},
547                                 ]),"\n",
548                         comment("Created by ".$version),"\n",
549                         start_center,"\n",
550                         h1($title),"\n",
551                         table({-class=>'ipage'},
552                                 Tr(td(img({-src=>$imgsrc,
553                                            -class=>'thumbnail',
554                                            -alt=>$title})),
555                                         td($self->infotable))),
556                         a({-href=>'../index.html',-class=>'conceal'},
557                                 'Index'),"\n",
558                         end_center,"\n",
559                         end_html,"\n";
560                 close($F);
561         }
562 }
563
564 sub startindex {
565         my $self = shift;
566         my $fn = $self->{-fullpath}.'/index.html';
567         my $block = $self->{-fullpath}.'/.noindex';
568         $fn = '/dev/null' if ( -f $block );
569         my $IND;
570         unless (open($IND,'>'.$fn)) {
571                 warn "cannot open $fn: $!";
572                 return;
573         }
574         binmode($IND, ":utf8");
575         $self->{-IND} = $IND;
576
577         my $inc = $self->{-inc}.$incdir.'/';
578         my $title = $self->{-title};
579         my $titleimage = $self->{-titleimage};  
580         print $IND start_html(-title => $title,
581                         -encoding=>"utf-8",
582                         -style=>[
583                                 {-src=>$inc."gallery.css"},
584                                 {-src=>$inc."custom.css"},
585                         ],
586                         -script=>[
587                                 {-src=>$inc."mootools.js"},
588                                 {-src=>$inc."overlay.js"},
589                                 {-src=>$inc."urlparser.js"},
590                                 {-src=>$inc."multibox.js"},
591                                 {-src=>$inc."showwin.js"},
592                                 {-src=>$inc."controls.js"},
593                                 {-src=>$inc."show.js"},
594                                 {-src=>$inc."gallery.js"},
595                         ]),"\n",
596                 comment("Created by ".$version),"\n",
597                 start_div({-class => 'indexContainer',
598                                 -id => 'indexContainer'}),
599                 "\n";
600         my $EVL;
601         if (open($EVL,$self->{-toppath}.'/'.$incdir.'/header.pl')) {
602                 my $prm;
603                 while (<$EVL>) {
604                         $prm .= $_;
605                 }
606                 close($EVL);
607                 %_ = (
608                         -version        => $version,
609                         -depth          => $self->{-depth},
610                         -title          => $title,
611                         -titleimage     => $titleimage,
612                         -path           => $self->{-fullpath},
613                         -breadcrumbs    => "breadcrumbs unimplemented",
614                 );
615                 print $IND eval $prm,"\n";
616         } else {
617                 print STDERR "could not open ",
618                         $self->{-toppath}.'/'.$incdir.'/header.pl',
619                         " ($!), reverting to default header";
620                 print $IND a({-href=>"../index.html"},"UP"),"\n";
621                 if ($titleimage) {
622                         print $IND img({-src=>$titleimage,
623                                         -class=>'titleimage',
624                                         -alt=>'Title Image'}),"\n";
625                 }
626                 print $IND h1({-class=>'title'},$title),
627                         br({-clear=>'all'}),"\n";
628         }
629 }
630
631 sub endindex {
632         my $self = shift;
633         my $IND = $self->{-IND};
634
635         print $IND end_div;
636         my $EVL;
637         if (open($EVL,$self->{-toppath}.'/'.$incdir.'/footer.pl')) {
638                 my $prm;
639                 while (<$EVL>) {
640                         $prm .= $_;
641                 }
642                 close($EVL);
643                 %_ = (
644                         -version        => $version,
645                         -depth          => $self->{-depth},
646                         -title          => $self->{-title},
647                         -titleimage     => $self->{-titleimage},
648                         -breadcrumbs    => "breadcrumbs unimplemented",
649                 );
650                 print $IND eval $prm,"\n";
651         } else {
652                 print STDERR "could not open ",
653                         $self->{-toppath}.'/'.$incdir.'/footer.pl',
654                         " ($!), reverting to default empty footer";
655         }
656         print $IND end_html,"\n";
657
658         close($IND) if ($IND);
659         undef $self->{-IND};
660 }
661
662 sub startsublist {
663         my $self = shift;
664         my $IND = $self->{-IND};
665
666         print $IND h2({-class=>"atitle"},"Albums"),"\n",start_table,"\n";
667 }
668
669 sub sub_entry {
670         my $self = shift;
671         my $IND = $self->{-parent}->{-IND};
672         my $name = $self->{-base};
673         my $title = $self->{-title};
674
675         $self->{-parent}->{-numofsubs}++;
676         print $IND Tr(td(a({-href=>$name.'/index.html'},$name)),
677                         td(a({-href=>$name.'/index.html'},$title))),"\n";
678 }
679
680 sub endsublist {
681         my $self = shift;
682         my $IND = $self->{-IND};
683
684         print $IND end_table,"\n",br({-clear=>'all'}),hr,"\n\n";
685 }
686
687 sub startimglist {
688         my $self = shift;
689         my $IND = $self->{-IND};
690         my $first = $self->{-firstimg}->{-base};
691         my $slideref = sprintf(".html/%s-slide.html",$first);
692
693         print $IND h2({-class=>"ititle"},"Images ",
694                 a({-href=>$slideref,-class=>'showStart',-rel=>'i'.$first},
695                         '&gt; slideshow')),"\n";
696 }
697
698 sub img_entry {
699         my $self = shift;
700         my $IND = $self->{-parent}->{-IND};
701         my $name = $self->{-base};
702         my $title = $self->{-info}->{'Comment'};
703         $title = $name unless ($title);
704         my $thumb = $self->{$sizes[0]}->{'url'};
705         my $info = $self->{-info};
706         my ($w, $h) = dim($info);
707
708         my $i=0+$self->{-parent}->{-numofimgs};
709         $self->{-parent}->{-numofimgs}++;
710
711         print $IND a({-name=>$name}),"\n",
712                 start_table({-class=>'slide'}),start_Tr,start_td,"\n";
713         print $IND div({-class=>'slidetitle'},
714                         "\n ",a({-href=>".html/$name-info.html",
715                                 -title=>'Image Info: '.$name,
716                                 -class=>'infoBox'},
717                                 $title),"\n"),"\n",
718                 start_div({-class=>'slideimage'});
719         if ($self->{-geoloc}) {
720                 my ($la,$lo) = @{$self->{-geoloc}};
721                 print $IND a({-href=>"http://maps.google.com/".
722                                                 "?q=$la,$lo&ll=$la,$lo",
723                                 -title=>"$la,$lo",
724                                 -class=>'geoloc'},
725                                 div({-class=>'geoloc'},"")),"\n";
726         }
727         print $IND a({-href=>".html/$name-static.html",
728                                 -title=>$title,
729                                 -class=>'showImage',
730                                 -rel=>'i'.$name},
731                                 img({-src=>$thumb,
732                                      -class=>'thumbnail',
733                                      -alt=>$title})),"\n",end_div,
734                 start_div({-class=>'varimages',-id=>'i'.$name,-title=>$title}),"\n";
735         foreach my $sz(@sizes) {
736                 my $src=$self->{$sz}->{'url'};
737                 my $w=$self->{$sz}->{'dim'}->[0];
738                 my $h=$self->{$sz}->{'dim'}->[1];
739                 print $IND "  ",a({-href=>$src,
740                         -class=>"conceal",
741                         -rel=>$w."x".$h,
742                         -title=>"Reduced to ".$w."x".$h},
743                         $w."x".$h)," \n";
744         }
745         print $IND "  ",a({-href=>$name,
746                                 -rel=>$w."x".$h,
747                                 -title=>'Original'},$w."x".$h),
748                 "\n",end_div,"\n",
749                 end_td,end_Tr,end_table,"\n";
750 }
751
752 sub endimglist {
753         my $self = shift;
754         my $IND = $self->{-IND};
755
756         print $IND br({-clear=>'all'}),hr,"\n\n";
757 }
758
759 sub infotable {
760         my $self = shift;
761         my $info = $self->{-info};
762         my $msg='';
763
764         my @infokeys=(
765                 'DateTime',
766                 'ExposureTime',
767                 'FNumber',
768                 'Flash',
769                 'ISOSpeedRatings',
770                 'MeteringMode',
771                 'ExposureProgram',
772                 'FocalLength',
773                 'FileSource',
774                 'Make',
775                 'Model',
776                 'Software',
777         );
778         $msg.=start_table({-class=>'infotable'})."\n";
779         foreach my $k(@infokeys) {
780                 $msg.=Tr(td($k.":"),td($info->{$k}))."\n" if ($info->{$k});
781         }
782         $msg.=end_table."\n";
783 }
784