The Kermit Photoalbum Script

Frank da Cruz, Columbia University
fdc@columbia.edu
9 July 2006

The photoalbum script demonstrates some new features of C-Kermit 8.0.212:

Given a directory containing JPG images, this script creates a website like this one:

http://www.columbia.edu/~fdc/museum

composed of:

The script calls upon the Image Magick component convert, if available, to create the thumbnails. If convert is not available, the index page simply contains links to each image page. (Click on the links in this paragraph to find Image Magick for Windows or Unix.)

This script requires C-Kermit 8.0.212 Dev.20 or later, which includes the new \fpictureinfo() function. Thus it will not fully work in the current version (2.1.3) of Kermit 95; but it still creates a website of unscaled pictures with all their links functioning, and an index with links rather than thumbnails.

At the core of the script is the new \fpictureinfo() function:

\fpictureinfo(filename[,array-designator])
The filename must indicate a JPG (.jpg or .jpeg) or GIF (.gif) file. The function examines the file's contents to determine the height and width of the image. If the width is greater than the height, the function returns the digit 1; if the height is greater than the width, the function returns 2. If the dimensions can't be determined for any reason, the function returns 0. If the optional array designator is included, e.g.:

.orientation := \fpictureinfo(foo.jpg,&d)

then the array is created (destroying any previously existing array of the same name) and element 1 is set to the image width (in pixels) and element 2 to the height (in pixels).

Suppose you have some JPG images in a directory on your PC. Make a directory on your web server to hold them, cd to that directory, go back to Kermit on your PC upload them. Then run this script. Command-line options are as follows. If any option contains spaces, enclose the entire option in doublequotes or curly braces.

Option Description Default
title=text Title for the Web page (enclose in quotes if it contains spaces) Photos
color=name Text color for Web page. Use any color name understood by your browser or "#xxxxxx" notation. Maroon
background=name Background color for Web page. Use any color name understood by your browser or "#xxxxxx" notation. Beige
Language=name English or Spanish English
Height=number Height in pixels for thumbnails 72
Noscale=number 0 = Scale pictures for Web browser; nonzero = don't scale. 0

Examples:

photoalbum
(no options)   Creates a web page called Photos using the default color scheme, creating thumbnails 72 pixels high if the Image Magick convert program is available.

photoalbum "title=Our Trip to Iceland"
The same, but the given title is used.

photoalbum "title=Our Trip to Iceland" color=blue background=#4444ff
The same, but with the given title and color scheme.

photoalbum "title=Santo Domingo" color=green background=yellow lang=Spanish
The same, but with a different title and in Spanish.

photoalbum height=100
Creates a web site with all the defaults, except thumbnails will be 100 pixels high instead of 72. If any thumbnails already exist that are not 100 pixels high, they are replaced.

After you have created your website, you can go back and edit the pages to add explanatory text. Don't do this until you are completely satisfied with the picture selection and color scheme, etc, because every time you run the photoalbum script, it replaces all the HTML pages.

To install the script in Unix...

  1. Install the C-Kermit 8.0.212 Dev.20 or later binary in any directory that's in your PATH. Use "chmod +x" to give it execute permission.
  2. Save the photoalbum script file on disk in any directory that's in your PATH. Use "chmod +x" to give it execute permission.
  3. Change the first line (the "kerbang line") of the photoalbum script file to indicate the full path of the C-Kermit 8.0.212 binary from step 1. CLICK HERE for details.

In Windows...

You can run the script from the Kermit 95 prompt with a TAKE command. First CD (in Kermit 95) to the directory containing the JPGs. Then tell K95 to TAKE the script (give the full or relative pathname if it's not in the current directory), with any desired options on the TAKE command line following the script name. You'll get lots of error messages but it will create a little website. Tell Kermit 95 to "run start index.html" to see it.


The Kermit Project / Columbia University / kermit@columbia.edu / 9 July 2006