summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@server-speed.net>2011-03-09 17:13:41 +0100
committerFlorian Pritz <bluewind@server-speed.net>2011-03-09 17:13:41 +0100
commit1145c28c23b2ca679022e78247f3a386332d269b (patch)
treecf6f12358740b5163381e51037c6635c2bf68c84
parent710b0068979018156db417a14e4273f51fc96e19 (diff)
downloadgenerate_gallery-1145c28c23b2ca679022e78247f3a386332d269b.tar.gz
generate_gallery-1145c28c23b2ca679022e78247f3a386332d269b.tar.xz
add options and make Image::ExifTool optional
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
-rwxr-xr-xgenerate_gallery.pl23
1 files 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)." <directory>...\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 .= "<div class=\"thumbnail\">\n";
- my $tags = ImageInfo($file, "Aperture", "ShutterSpeed", "FocalLength");
- $html .= "<a rel=\"images\" class=\"thumbnail\" title=\"".$tags->{ShutterSpeed}."s, ".$tags->{FocalLength}." @ F ".$tags->{Aperture}."\" href=\"$file\">\n";
+ $html .= "<a rel=\"images\" class=\"thumbnail\" ";
+ if ($opts{exif}) {
+ my $tags = ImageInfo($file, "Aperture", "ShutterSpeed", "FocalLength");
+ $html .= "title=\"".$tags->{ShutterSpeed}."s, ".$tags->{FocalLength}." @ F ".$tags->{Aperture}."\"";
+ }
+ $html .= "href=\"$file\">\n";
$html .= "<img class=\"thumbnail\" alt=\"\" src=\"thumbs/$file\" />\n";
$html .= "</a>\n</div>\n";
}