Make a list of JPEGs into a slide show

#! /usr/bin/perl -w
use strict;

############################################################
#                                                          #
#                                                          #
#                                                          #
#                  NOAH SUSSMAN                            #
#                                                          #
#                  showserial.pl                           #
#                                                          #
#                Created 10/8/3 at 1.41am                  #
#                                                          #
#    Show jpegs one-per-page on a series of hyperlinked    #
#    web pages.  Purpose is to provide a good _linear_     #
#    viewing mechanism for jpegs on the palm.              #
#    Adapted from showsm.pl                                #
#                                                          #
#                                                          #
############################################################

my @images;

while (<*.jp*>) {
push @images, $_;  #read image filenames into a list
}

shift @images;  #first image is never the subject of  a "next" hyperlink

while (<*.jp*>) {  #regex captures any filename with extension beginning "JP"

my $next_file;
$next_file = $images[0]; #read the next filename into $next_file
shift @images; #manually discard the value we just read into $next_file

my $out="$_";
$out =~ s/jpeg/html/gio;
open OUT, ">$out" or die "Cannot open $out for write :$!";

if ($next_file){
#print $next_file;
$next_file =~ s/jpeg/html/gio;
print OUT "<a href="$next_file">";
}

print OUT "<html><head><title>$_</title></head><body>
";
print OUT "<img src="$_" >
";  #an image tag points to each file name
print OUT "</body></html>";

if ($next_file){
print OUT "</a>";
}
}

source

Leave a Reply