#!/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; if (@ARGV == 0) { print "usage: ".basename($0)." ...\n"; exit 0; } my $templatedir = abs_path(dirname($0))."/generate_gallery.d"; my $startdir = cwd(); for my $dir (@ARGV) { chdir $startdir; unless (-d $dir) { print "Argument is not a directory: $dir. Ignoring.\n"; 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"; 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"; my $tags = ImageInfo($file, "Aperture", "ShutterSpeed", "FocalLength"); $html .= "{ShutterSpeed}."s, ".$tags->{FocalLength}." @ F ".$tags->{Aperture}."\" href=\"$file\">\n"; $html .= "\"\"\n"; $html .= "\n
\n"; } open TEMPLATE, "<", "$templatedir/template.html"; open OUTPUT, ">", "$abs_dir/index.html"; while (