From 1145c28c23b2ca679022e78247f3a386332d269b Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 9 Mar 2011 17:13:41 +0100 Subject: add options and make Image::ExifTool optional Signed-off-by: Florian Pritz --- generate_gallery.pl | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/generate_gallery.pl b/generate_gallery.pl index 931581d..f79c433 100755 --- a/generate_gallery.pl +++ b/generate_gallery.pl @@ -1,11 +1,12 @@ #!/usr/bin/perl use warnings; use strict; -use Image::ExifTool qw(ImageInfo); use File::Basename; use Cwd qw(cwd abs_path); use File::MimeInfo qw(mimetype); use Image::Magick; +use Getopt::Long; +use Module::Load; if (@ARGV == 0) { print "usage: ".basename($0)." ...\n"; @@ -16,10 +17,18 @@ my $templatedir = abs_path(dirname($0))."/generate_gallery.d"; my $startdir = cwd(); +my %opts = (); +GetOptions(\%opts, "exif|e", "verbose|v", "help|h"); + + +if ($opts{exif}) { + load Image::ExifTool, "ImageInfo"; +}; + for my $dir (@ARGV) { chdir $startdir; unless (-d $dir) { - print "Argument is not a directory: $dir. Ignoring.\n"; + print "Argument is not a directory: $dir. Ignoring.\n" if $opts{verbose}; next; } my $abs_dir = abs_path $dir; @@ -29,7 +38,7 @@ for my $dir (@ARGV) { for my $file (glob("*")) { unless (mimetype($file) =~ /^image\/.*/) { - print "ignoring non-image: $dir/$file\n"; + print "ignoring non-image: $dir/$file\n" if $opts{verbose}; next; } @@ -41,8 +50,12 @@ for my $dir (@ARGV) { $img->Write("$abs_dir/thumbs/$file"); } $html .= "\n"; } -- cgit v1.2.3-24-g4f1b