for all subdirectories ("Albums"); if you wish to recreate the titles,
remove ".title" files. If you *don't* want "index.html" to be generated
in some directory, create a file ".noindex". This way you can preserve
-index created by hand or by some other script.
+index created by hand or by some other script like "mkindex.pl".
+
+command-line options:
+ --debug: print a lot of debugging info to stdout as you run
+ --asktitle: ask to edit subalbum titles even if there are ".title" files
+ --noasktitle: don't ask to enter subalbum titles even where ".title"
+ files are absent. Use partial directories as titles.
+
+The only way to specify titles for individual pictures is to write
+comments into the image files.
"mkindex.pl" is a simple script that is completely unrelated to the
gallery (theoretically). If your tree starts with YYYY/DD (four
Requirements:
Image::Info
-Image::Magick (might get rid of that later)
-Term::ReadLine (not at this moment but planned)
+Image::Magick (optional. If not present, will run djeg|pnmscale|cjpeg pipe)
+Term::ReadLine
Download:
svn co svn://svn.average.org/mkgallery/trunk mkgallery
TODO:
-- build html and indices only if image/directory changed
-- make Image::Magick optional
-- anything else that I forgot
+- any ideas?
Eugene Crosser <crosser at average dot org>
use Term::ReadLine;
use Getopt::Long;
-use Image::Magick;
+my $haveimagick = eval { require Image::Magick; };
+{ package Image::Magick; } # to make perl compiler happy
my @sizes = (160, 640);
while (my $de = readdir($D)) {
next if ($de =~ /^\./);
my $child = $self->new($de);
+ my @stat = stat($child->{-fullpath});
+ $youngest = $stat[9] if ($youngest < $stat[9]);
if ($child->isdir) {
push(@rdirlist,$child);
} elsif ($child->isimg) {
- my @stat = stat($child->{-fullpath});
- $youngest = $stat[9] if ($youngest < $stat[9]);
push(@rimglist,$child);
}
}
$dir->iterate;
}
-# no need to go beyond this point if the directory timestamp did not
-# change since we built index.html file last time.
-
- my @istat = stat($self->{-fullpath}.'/index.html');
- return unless ($youngest > $istat[9]);
-
# 3. iterate through images to build cross-links,
my $previmg = undef;
$img->makeaux;
}
+# no need to go beyond this point if the directory timestamp did not
+# change since we built index.html file last time.
+
+ my @istat = stat($self->{-fullpath}.'/index.html');
+ return unless ($youngest > $istat[9]);
+
# 5. start building index.html for the directory
$self->startindex;
sub doscaling {
my ($src,$dest,$factor,$w,$h) = @_; # this is not a method
- my $im = new Image::Magick;
- my $err;
- print "doscaling $src -> $dest by $factor\n" if ($debug);
- $err = $im->Read($src);
- unless ($err) {
- $im->Scale(width=>$w*$factor,height=>$h*$factor);
- $err=$im->Write($dest);
- warn "ImageMagick: write \"$dest\": $err" if ($err);
- } else { # fallback to command-line tools
- warn "ImageMagick: read \"$src\": $err";
+
+ my $err=1;
+ if ($haveimagick) {
+ my $im = new Image::Magick;
+ print "doscaling $src -> $dest by $factor\n" if ($debug);
+ if ($err = $im->Read($src)) {
+ warn "ImageMagick: read \"$src\": $err";
+ } else {
+ $im->Scale(width=>$w*$factor,height=>$h*$factor);
+ $err=$im->Write($dest);
+ warn "ImageMagick: write \"$dest\": $err" if ($err);
+ }
+ undef $im;
+ }
+ if ($err) { # fallback to command-line tools
system("djpeg \"$src\" | pnmscale \"$factor\" | cjpeg >\"$dest\"");
}
- undef $im;
}
sub makeaux {