#!/usr/bin/perl use warnings; use strict; 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"; exit 0; } 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" if $opts{verbose}; next; } my $abs_dir = abs_path $dir; chdir $abs_dir; mkdir "thumbs" unless -d "thumbs"; my $html; for my $file (glob("*")) { unless (mimetype($file) =~ /^image\/.*/) { print "ignoring non-image: $dir/$file\n" if $opts{verbose}; next; } unless ( -e "$abs_dir/thumbs/$file") { print "processing $dir/$file ...\n"; my $img = new Image::Magick; $img->Read("$abs_dir/$file"); $img->Thumbnail(geometry=>"200x200"); $img->Write("$abs_dir/thumbs/$file"); } $html .= "
\n"; $html .= "{ShutterSpeed}."s, ".$tags->{FocalLength}." @ F ".$tags->{Aperture}."\""; } $html .= "href=\"$file\">\n"; $html .= "\"\"\n"; $html .= "\n
\n"; } open TEMPLATE, "<", "$templatedir/template.html"; open OUTPUT, ">", "$abs_dir/index.html"; while (