diff options
-rwxr-xr-x | generate_gallery.pl | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/generate_gallery.pl b/generate_gallery.pl index 6f68cd5..0d3996c 100755 --- a/generate_gallery.pl +++ b/generate_gallery.pl @@ -14,7 +14,11 @@ my $templatedir = abs_path(dirname($0))."/generate_gallery.d"; my $startdir = cwd(); my %opts = (); -GetOptions(\%opts, "exif|e", "verbose|v", "help|h", "filenamedesc") or pod2usage(2); + +$opts{template} = "$templatedir/template.html"; +$opts{thumbnailsize} = 200; + +GetOptions(\%opts, "exif|e", "verbose|v", "help|h", "filenamedesc", "template=s", "thumbnailsize|s=i", "htmlonly") or pod2usage(2); pod2usage(0) if $opts{help}; pod2usage(-verbose => 0) if (@ARGV== 0); @@ -23,6 +27,12 @@ if ($opts{exif}) { load Image::ExifTool, "ImageInfo"; }; +$opts{template} = abs_path($opts{template}); +unless (-r $opts{template}) { + print STDERR "Error: template file not readable: $!\n"; + exit 1; +} + for my $dir (@ARGV) { chdir $startdir; unless (-d $dir) { @@ -45,7 +55,7 @@ for my $dir (@ARGV) { print "processing $dir/$file ...\n"; my $img = new Image::Magick; $img->Read("$abs_dir/$file"); - $img->Thumbnail(geometry=>"200x200"); + $img->Thumbnail(geometry=>$opts{thumbnailsize}."x".$opts{thumbnailsize}); $img->Write("$abs_dir/thumbs/$file"); } @@ -67,7 +77,7 @@ for my $dir (@ARGV) { $html .= "<img class=\"thumbnail\" alt=\"\" src=\"thumbs/$file\" />\n"; $html .= "</a>\n</div>\n"; } - open TEMPLATE, "<", "$templatedir/template.html"; + open TEMPLATE, "<", "$opts{template}"; open OUTPUT, ">", "$abs_dir/index.html"; while (<TEMPLATE>) { if (/%%CONTENT%%/) { @@ -78,7 +88,9 @@ for my $dir (@ARGV) { } close TEMPLATE; close OUTPUT; - system "cp", "-r", "$templatedir/fancybox", "."; + unless ($opts{htmlonly}) { + system "cp", "-r", "$templatedir/fancybox", "."; + } } __END__ @@ -91,10 +103,14 @@ generate_gallery.pl - Generate simple, static HTML gallery generate_gallery.pl [options] <directory ...> Options: - --help, -h short help message - --verbose, -v be verbose during operation - --exif, -e add exif information of each image to the page - --filenamedesc add the filename to the description + --help, -h short help message + --verbose, -v be verbose during operation + --exif, -e add exif information of each image to the page + --filenamedesc add the filename to the description + --template <file> change template file to use + --htmlonly don't copy the fancybox directory + --thumbnailsize, -s <size> change size of the thumbnails in pixels + (default: 200) =head1 OPTIONS @@ -119,6 +135,18 @@ This is only recomended for pictures taken with digital cameras. Add the filename to the image description. The extension will be stripped. +=item B<--template <file> + +Change the template file to use. The file should contain the string "%%CONTENT%%". + +=item B<--htmlonly + +Only generate thumbnails and the html file. This disables copying of fancybox. + +=item B<--thumbnailsize, <-s <size> + +Change the size of the generated thumbnails in pixels. Default: 200 + =back =head1 DESCRIPTION |