#!/usr/local/bin/perl ############################################################################## $VERSION='gif2html.pl v1.25'; # 22 April 1997 Dale Bewley #$VERSION='gif2html.pl v1.11'; # 4 Dec. 1996 Dale Bewley #$VERSION='gif2html.pl v1.1'; # 24 Oct. 1996 Dale Bewley # v1.0 Oct. 96, v1.0b4 25 July 96, v.99 12 June 96, v.09 26 Sept. 95 #----------------------------------------------------------------------------- # # This script and others found at http://www.bewley.net/perl/ # # Creates an html file for each graphic in a directory. Useful for creating # a slide show. See slideshow.pl on my perl page above. # # See POD at bottom of file for instructions. # # # Copyright (C) 1995, 1996, 1997 Dale Bewley # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ############################################################################## #- User Configurable Variables ----------------------------------------------# #$BACKGROUND = "http://www.iupui.edu/home/Graphics/emboss.gif"; $CAPTION_FILE = ".gif2html.cap"; # default file of captions $TEMPLATE_FILE = ".gif2html.tmp"; # default HTML template in current dir $BASEREF = "./"; # to prefix IMG SRC's #----------------------------------------------------------------------------# #- Help! --------------------------------------------------------------------# sub help { # help a lost soul print < http://www.bewley.net/perl/gif2html.pl.html Description: This script will create an HTML file for each of a batch of graphics. Usage: $0 [] Options: -b Baseref for all URLs in output. -g Background for output files (unused) -c .gif2html.cap Use this file for caption mappings. -h This message. -t .gif2html.tmp Use this template file. -v Verbose. Filespec: Any pattern that names your graphics, i.e. luther.gif *.gif *.jpg * *.* Example: $0 -c captions.txt -v *.gif *.jpg E_O_HELP 1; } #----------------------------------------------------------------------------# #- Main Program -------------------------------------------------------------# use vars qw($BACKGROUND $CAPTION_FILE $TEMPLATE_FILE $BASE_REF $opt_h); # many problems with pod2usage unfortunately. May have to dump it. #use Pod::Usage; # If you have Image::Size installed uncomment this #use Image::Size 'html_imgsize'; # see CPAN/modules/by-module/Image/ require('getopt.pl') || print STDERR "Waring! get getopt.pl\n"; &getOpts; # get commandline options # either this line or the pod2usage line below... if ((!$ARGV[0]) || ($opt_h)) { &help && exit; } # give help and exit # why all these use Strict-ish errors?! if ((!$ARGV[0]) || ($opt_h)) { pod2usage(); } # give help and exit #pod2usage({EXIT => 0, VERBOSE => 2}) if ($opt_h); # gives lots of help and exit @gfxFiles = @ARGV; # queue up the gfx print STDERR scalar(@gfxFiles), " gfx to process\n" if ($opt_v); @TEMPLATE = &readTemplate($TEMPLATE_FILE); # read html template my %CAPTIONS; &readCaptions($CAPTION_FILE,\%CAPTIONS); # read gfx captions foreach (@gfxFiles) { &writeFile($_,@TEMPLATE); } # write the html files #----------------------------------------------------------------------------# #- Get Command Line Opts ----------------------------------------------------# sub getOpts { &Getopt('cbgt'); # these options accept commandline values $BASEREF = $opt_b if ($opt_b); $CAPTION_FILE = $opt_c if ($opt_c); $BACKGROUND = $opt_g if ($opt_g); # unused! $TEMPLATE_FILE = $opt_t if ($opt_t); } #----------------------------------------------------------------------------# #- Read HTML Template -------------------------------------------------------# sub readTemplate { # get html template to put graphics into. local($template) = shift @_; local(@template); if (open(TEMPLATE, "$template")) { print STDERR "reading template file: $template\n" if ($opt_v); @template =