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