I found a perl CGI script to do this:
#!/usr/bin/perl -wT
# myscript.pl
use strict;
use CGI;
use Image::Size;
my $q = new CGI;
my $imageDir = "./";
my @images;
opendir DIR, "$imageDir" or die "Can't open $imageDir $!";
@images = grep { /\.(?:png|gif|jpg)$/i } readdir DIR;
# @images = grep { /\.(?:png|gif|jpg|webm|web|mp4|svg)$/i } readdir DIR;)
closedir DIR;
print $q->header("text/html"),
$q->start_html("Images in the directory you specified."),
$q->h1("Images in the directory your specified.");
foreach my $image (@images) {
my ($width, $height) = imgsize("$image");
print $q->a({-href=>$image},
$q->img({-src=>$image,
-width=>$width,
-height=>$height})
);
}
print $q->end_html;
to run on MacOS you'll need to install these modules like this:
cpan CGI
cpan Image::Size
Put the sript in the directory that contains the images you want to preview.
…then say perl -wT myscript.pl > output.html
Open the generated output.html
to see all the images in a single browser window at their natural dimensions.
Related to this question and answer: How to run this simple Perl CGI script on Mac from terminal?