0

What's a good command from term to render all images in a dir into one browser window?

Looking for something like this:

python -m SimpleHTTPServer 8080

But instead of a list ...

... Would like to see all the images rendered in a single browser window, just flowed naturally, at natural dimensions, just scroll down for how many images there are to see them all in their natural rendered state.

Rowe Morehouse
  • 4,451
  • 3
  • 28
  • 28

2 Answers2

0

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?

Rowe Morehouse
  • 4,451
  • 3
  • 28
  • 28
-2

This is quite easy, you can program something like this in a couple of minutes. Just create an array of all the images in ./ create a var s = '' and appen for each img in ./ '>
' and send it to the webbrowser the server->google is your friend

Felipe
  • 80
  • 7