NAME

list-pics.pl, index.cgi - Displays individual pictures in a directory.

SYNOPSIS

When accessed by a web server with no arguments, this program displays a list of images in the current directory with one-line descriptions. Any thumbnail images in the directory will be displayed in-line.

When a single image is selected, it is displayed along with its one-line description. Included on the page are hyperlinks to the previous image, the next image, and the index. Clicking on the image will bring up the image by itself (allowing the browser to resize the image or not).

When invoked from the command line as "./index.cgi -", it updates its database and creates thumbnail images if needed.

DESCRIPTION

To install this program, simply save it as text and copy it to a directory that has GIF, JPG or PNG images. Rename the file to be index.cgi. On Unix systems, mark the file as being executable by using the command "chmod +x index.cgi". (This program also works on Win-95/98/NT web servers that recognize "index.cgi" as a default document.)

There are three modes of operation:

Format of index.txt

The basic format is 'filename', 'spaces and/or tabs', 'description'. For example:

  #             Comment: Pet ID tag, DOB, etc
  .             Pictures of my handsome cat
  ..            Other pets in our house
  -             index=Murdock.html dates
  Murdock1.jpg  Sleeping
  Murdock2.jpg  Eating

The one-line descriptions can actually be more than one line long. Any line that starts with leading blanks or tabs is a continuation of the previous line. Simple HTML can be used in the description, such as <a href=""></a> and <b>...</b>.

Comments can be placed in the file by using "# Text".

The description for '.' will appear on each page; it should be a description of the current directory. This is <h1> on the directory page and italics on the individual pictures pages.

The description for '..' will be used on the index page where it links to the parent directory.

Options for the program are set via index.txt using the description for '-'. These are described under "OPTIONS".

Images can be grouped together by using blank lines as separators.

Format of .index.txt

The file .index.txt is recreated whenever there is a newer file in the directory when invoked as "./index.cgi -". There is no need to manually edit this file. It has image-type, width, height, filename. Supported image-types are those handled by Image::Size and `ffprobe`.

Installation hints

Save a copy of this file as 'index.cgi' in a directory full of images. For UNIX users, the easiest way is to go to the shell and use:

   lynx -source 'http://www.inwap.com/mybin/index.cgi?list-pics.pl' >temp
or
   wget -O temp 'http://www.inwap.com/mybin/index.cgi?list-pics.pl'
   chmod 755 temp
   cp temp public_html/img/index.cgi; rm temp

If you have more than one directory full of images, 'cd' into each one and then use

   ln $HOME/public_html/img/index.cgi .

to make a hard link to the script. Using 'ln' instead of 'cp' makes it possible to update all the copies at once when a newer version becomes available. (The instructions above use 'temp' so that will work right.)

Then, while in the directory with image files, use the command "./index.cgi -" to create (or update) the index.txt file (and .index.txt). Be sure to edit index.txt to put images in order and separate groups with a blank line.

Another way to get list-pics.pl is to go to http://www.inwap.com/mybin/ and view list-pics.pl. Use the browser's menu, "File | Save As | Source", and save using the name index.cgi. Then use the ftp program to upload the file to the web server. Be sure to use ASCII mode. You will need to "chmod 755 index.cgi" before or after the transfer.

This program can also be used on Windows-95/98/NT by any web server that can handle CGI programs written in perl (such as the one written by Tod Sambar for Win-95).

Preparing the images

Many digital cameras create JPG images with unreasonably high 'Q' values. The size of the file can be reduced to 1/3rd or 1/4th of its original size by simply resaving the file with a 'Q' value of 75. Thumbs Plus from http://www.cerious.com/ has a batch-conversion mode that can do this.

When tranferring images from the Olympus digital camera, there are two annoyances: The file names are PIC00001.JPG through PIC00120.JPG, and the date on the file is when it was downloaded, not when the picture was taken. The program 'rename-oly' in http://www.inwap.com/mybin/ fixes both problems.

OPTIONS

Options are declared in the index.txt file on the line for '-'.

  dates nodates                 Shows or suppresses (default) listing file's date
  thumbnails nothumbnails       Shows (default) or suppresses in-line thumbnails
  bgcolor="black"               Added to <body> tag, default is "#dddddd"
  background="image"            Added to <body> tag
  text="white"                  Added to <body> tag
  link="blue" vlink="violet"    Added to <body> tag
  bgimage="clear"               Background for transparent GIFs, "black", "white" or "clear"
  thumbwidth=570                Limits total width for in-line thumbnails
  index="index.html"            Allows alternate index file
  namewidth=20                  Truncates long file name to 20 characters

NOTES

Avoid using file names with embedded spaces or '#' characters. (Those two special characters in URLs confuse many browsers.) File names with embedded blanks can be listed in index.txt by using a tab after the file name.

ENVIRONMENT

When run by the web server, these are part of the CGI protocol.

  SCRIPT_NAME           Name of this script (if not 'index.cgi')
  QUERY_STRING          Name of image to be displayed
  REQUEST_URI           Name of virtual directory being displayed

When run from the command line

  USER                  Signifies command-line mode when set
  PATH                  Used to locate 'djpeg', 'ffprobe' and PBM utilities

FILES

  index.txt             Descriptions of the images
  .index.txt            Width and height of images and thumbnails
  HEADER.txt            Plain text to be output before the directory index
  HEADER.html           HTML  text to be output before the directory index
  README.txt            Plain text to be output after the directory index
  README.html           HTML  text to be output after the directory index

EXTERNAL PROGRAMS

When creating thumbnails, the following programs may be used:

  djpeg                 Creates 1/8th scale thumbnail GIF from a JPG image v6
  xvpictoppm|ppmtogif   Create thumbnail GIF from an 'xv-3.10' thumbnail
  pnmscale|ppmquant     Create scaled thumbnail GIF from an image
  ffprobe               Returns width and height of various movie files
  pngtopnm              Converts PNG

DIAGNOSTICS

Error messages are displayed as HTML to the user. Only one is expected to occur; "Unable to read directory" happens when the directory is accidentally protected against reading.

BUGS

Does not create thumbnails from first frame of movie files.

AUTHOR

Joe Smith - joeinwap,gmail

SEE ALSO

Other programs that can be found at http://www.inwap.com/mybin/

  list-files.pl         Lists files in a directory in alphabetical order
  list-imgs             Recursively updates .index.txt for new images