summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2011-07-03 14:47:39 +0200
committerFlorian Pritz <bluewind@xinu.at>2011-07-03 14:47:39 +0200
commit6f4d9f8a9d170830bd01b24da8ab73f1744e9d11 (patch)
tree9e4f639c7df396309c14cd374443dadfbe569d78
parent7119abd14346553d14a8abf7ba3fe62f8fab747d (diff)
downloadgenerate_gallery-6f4d9f8a9d170830bd01b24da8ab73f1744e9d11.tar.gz
generate_gallery-6f4d9f8a9d170830bd01b24da8ab73f1744e9d11.tar.xz
add --filenamedesc; refactor how title attribute is generated
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xgenerate_gallery.pl25
1 files changed, 20 insertions, 5 deletions
diff --git a/generate_gallery.pl b/generate_gallery.pl
index a5f3c8b..6f68cd5 100755
--- a/generate_gallery.pl
+++ b/generate_gallery.pl
@@ -14,7 +14,7 @@ my $templatedir = abs_path(dirname($0))."/generate_gallery.d";
my $startdir = cwd();
my %opts = ();
-GetOptions(\%opts, "exif|e", "verbose|v", "help|h") or pod2usage(2);
+GetOptions(\%opts, "exif|e", "verbose|v", "help|h", "filenamedesc") or pod2usage(2);
pod2usage(0) if $opts{help};
pod2usage(-verbose => 0) if (@ARGV== 0);
@@ -35,6 +35,7 @@ for my $dir (@ARGV) {
my $html;
for my $file (glob("*")) {
+ my $description = "";
unless (mimetype($file) =~ /^image\/.*/) {
print "ignoring non-image: $dir/$file\n" if $opts{verbose};
next;
@@ -47,12 +48,21 @@ for my $dir (@ARGV) {
$img->Thumbnail(geometry=>"200x200");
$img->Write("$abs_dir/thumbs/$file");
}
- $html .= "<div class=\"thumbnail\">\n";
- $html .= "<a rel=\"images\" class=\"thumbnail\" ";
+
+ if ($opts{filenamedesc}) {
+ my $basename = basename($file);
+ $basename =~ s/(.*)\..*/$1/;
+ $description = $basename;
+ $description .= ": " if ($opts{exif});
+ }
if ($opts{exif}) {
my $tags = ImageInfo($file, "Aperture", "ShutterSpeed", "FocalLength");
- $html .= "title=\"".$tags->{ShutterSpeed}."s, ".$tags->{FocalLength}." @ F ".$tags->{Aperture}."\"";
+ $description .= $tags->{ShutterSpeed}."s, ".$tags->{FocalLength}." @ F ".$tags->{Aperture};
}
+
+ $html .= "<div class=\"thumbnail\">\n";
+ $html .= "<a rel=\"images\" class=\"thumbnail\" ";
+ $html .= "title=\"$description\"" if $description;
$html .= "href=\"$file\">\n";
$html .= "<img class=\"thumbnail\" alt=\"\" src=\"thumbs/$file\" />\n";
$html .= "</a>\n</div>\n";
@@ -84,6 +94,7 @@ generate_gallery.pl [options] <directory ...>
--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
=head1 OPTIONS
@@ -99,11 +110,15 @@ Be verbose.
=item B<--exif>, B<-e>
-Add the following exif information to the page:
+Add the following exif information to the image description:
shutter speed, ISO, focal length, aperture
This is only recomended for pictures taken with digital cameras.
+=item B<--filenamedesc
+
+Add the filename to the image description. The extension will be stripped.
+
=back
=head1 DESCRIPTION