NAME - create html files for images with caption and height width tags

v1.25 -

SYNOPSIS [ -h ] | [ -v ] [ -c captions file ] [ -t template file ] [ -b baseref ] filenames

Example: -v -t template.html *.gif *.jpg

Sample Output:


Use in batch jobs. It takes a butt load of graphics and creates an html file for each one, giving you complete control over the html. Simply create an html Template with an empty <img src=> in it. will copy the template for each image and fill in each <img src=> with the appropriate URL and width/height tags. It will also include unique Captions for each image.

Tested with UNIX of course and also Win95 Perl5.001m b107

Give your graphics descriptive names. Use full words seperated by a '-'. Dashes will be converted to spaces and possibly placed in the title depending on your template. Better yet, use the captions.

What's New

Can make use of the Image::Size module. The advantage is width and height tags can be generated for many more formats than just gif or jpeg. See your nearest node.

Template support

You have complete control over how the image will be presented. Create an html file like so:

<HTML> <HEAD><TITLE><S-INSERT TITLE></TITLE> <!-- This file created by by Dale Bewley --> </HEAD> <BODY> <center> <HR width=80%> <TABLE border=1> <TR> <TD><IMG SRC=""></TD></TR> </TABLE> <HR width=80%> <H3><S-INSERT CAPTION></H3> </center> </BODY> </HTML>

This template will be copied for each image to a file having the same name as the image but ending in .html. Also see the default template in sub readTemplate.

Notice the empty <IMG SRC=``''> tag. This will automagically be filled in with the URL of the graphic along with its width and height tags.

Also notice the <S-INSERT TITLE> and <S-INSERT CAPTION>. If you do not insert a title then the name of the graphic file will become the default title of the HTML file although dashes and underscores will be converted to spaces. The <S-INSERT CAPTION> will be filled in with the corresponding caption for the image.


Of course you can put html in them!

It is possible to create a custom caption for each image. Simply create a file that looks like so:

dale.gif | <h2>Vegan guy</h2> Means he don't eat no animal pieces or excretions. no-meat-graphic.jpg | Use this logo to make stickers for your local McD's jill.jpg | <B>Bestest</B> gurly in the <em>world</em>!

The first word must be a graphics filename followed by a | with optional spaces around it. The caption continues until a blank line and will be stuffed in place of the <S-INSERT CAPTION> tag in the template. Captions may span lines and must be seperated by a BLANK line. If you need a blank line in your caption for some reason (maybe you are useing &lt;PRE&gt;) then you need to put a space on the blank line.

If a graphic does not have a caption then will put the graphics name in as a caption, just as in the title.

Tell where to find this file by either specifying it on the command line with the -c option or putting its name in the $CAPTION_FILE user variable.


Command Line

-b URL
Baseref for all URLs in output.

-g URL
Background for output files (unused)

-c filename
Use this file for caption mappings. Default is .gif2html.cap.


-t filename
Use this template file. Default is .gif2html.tmp.

Verbose. Gives you a little feedback.


Script Variables

You may modify these variables to your heart's content.

$CAPTION_FILE = ``.gif2html.cap'';
Default file of captions.

$BASEREF = ``./'';
Where are the graphics located? This will prefix IMG SRC's. You might want to use this if you are running on a different box or in a different directory than where you will publish the output.

$TEMPLATE_FILE = ``.gif2html.tmp'';
Default HTML template in current dir.





Output of this program is particularly suited for and .

Old versions still hanging around:


Dale Bewley <>

Dale has recently started a business, Bewley Internet Solutions if you like this script why not send him a job, a check, or maybe just a book?