summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2011-08-04 09:41:37 +0200
committerFlorian Pritz <bluewind@xinu.at>2011-08-04 09:41:37 +0200
commitf872ca47b0b1d72d5780058f98534774f07b89d0 (patch)
tree37cad4c1f76584818002b1fd7cc06ec0470e8c3a
parent6f4d9f8a9d170830bd01b24da8ab73f1744e9d11 (diff)
downloadgenerate_gallery-f872ca47b0b1d72d5780058f98534774f07b89d0.tar.gz
generate_gallery-f872ca47b0b1d72d5780058f98534774f07b89d0.tar.xz
add options to change template and thgumbnail size
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xgenerate_gallery.pl44
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