summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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";
}