-sub mkauxfile {
- my ($start,$dir,$pbase,$base,$nbase,$refresh,$info) =@_;
- my $en=sprintf("%s/%s/.html/%s-%s.html",$start,$dir,$base,$refresh);
- my $pref;
- my $nref;
- if ($pbase) {
- $pref=sprintf("%s-%s.html",$pbase,$refresh);
- } else {
- $pref="../index.html";
- }
- if ($nbase) {
- $nref=sprintf("%s-%s.html",$nbase,$refresh);
- } else {
- $nref="../index.html";
- }
- my $toggle;
- my $toggleref;
- if ($refresh eq 'slide') {
- $toggle='Stop!';
- $toggleref=sprintf("%s-static.html",$base);
- } else {
- $toggle='Play->';
- $toggleref=sprintf("%s-slide.html",$base);
- }
-
- my $tdir=sprintf "%s/%s/.html",$start,$dir;
- mkdir($tdir,0755) unless ( -d $tdir );
-
- unless (open(STDOUT,">".$en)) {
- warn "cannot open $en: $!";
- return;
- }
- my $title=$info->{'Comment'};
- $title=$base unless ($title);
- if ($refresh eq 'slide') {
- print start_html(-title=>$title,
- -bgcolor=>"#808080",
- -head=>meta({-http_equiv=>'Refresh',
- -content=>"3; url=$nref"})),"\n";
- } else {
- print start_html(-title=>$title,
- -bgcolor=>"#808080"),"\n";
- }
- print start_center,"\n";
- print h1($title);
- print a({-href=>"../index.html"},"Index")," | ";
- print a({-href=>$pref},"<<Prev")," | ";
- print a({-href=>$toggleref},$toggle)," | ";
- print a({-href=>$nref},"Next>>");
- print p;
- print img({-src=>"../.640/".$base}),"\n";
- print end_center,"\n";
- print end_html,"\n";
- close(STDOUT);
-}
-
-sub scale {
- my ($start,$dir,$base,$fn,$tsize,$info)=@_;
- my ($w,$h) = dim($info);
- my $max=($w>$h)?$w:$h;
- my $factor=$tsize/$max;
-
- return $base if ($factor >= 1);
-
- my $tdir=sprintf "%s/%s/.%s",$start,$dir,$tsize;
- mkdir($tdir,0755) unless ( -d $tdir );
- my $tbase=sprintf ".%s/%s",$tsize,$base;
- my $tfn=sprintf "%s/%s",$tdir,$base;
- my @sstat=stat($fn);
- my @tstat=stat($tfn);
- return $tbase if (@tstat && ($sstat[9] < $tstat[9])); # [9] -> mtime
-
- print STDERR "scale by $factor from $fn to $tfn\n";
- &doscaling($fn,$tfn,$factor,$w,$h);
- return $tbase;
-}
-
-sub doscaling {
- my ($src,$dest,$factor,$w,$h)=@_;
-
- my $im=new Image::Magick;
- my $err;
- #print STDERR "doscale $src -> $dest by $factor\n";
- $err=$im->Read($src);
- unless ($err) {
- $im->Scale(width=>$w*$factor,height=>$h*$factor);
- $err=$im->Write($dest);
- warn "ImageMagic: write \"$dest\": $err" if ($err);
- } else {
- warn "ImageMagic: read \"$src\": $err";
- system("djpeg \"$src\" | pnmscale \"$factor\" | cjpeg >\"$dest\"");
- }
- undef $im;
-}