Frank da Cruz, Columbia University
[email protected]
9 July 2006
Last update: Wed Jul 13 17:49:51 2011
FTP links converted to HTTP: Sun Aug 1 20:20:35 2021
The photoalbum script demonstrates some new features of C-Kermit 9.0:
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 text 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 9.0 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.
At the core of the script is the new \fpictureinfo() function:
.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 on the web server. 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 |
Resize[=number] | Resize original JPGs to the given number of pixels (default 760), which is applied to the longest dimension of each picture. | Don't |
Noscale=number | 0 = Scale pictures for Web browser; nonzero = don't scale. | Scale |
The RESIZE option is useful when you have uploaded digital camera images that might be 300K, 1MB, or more each in size, which can be painful to view on the Web over slow connections. In any case, the extra detail is wasted in this case because we tell the Web browser to scale the image to fit anyway. RESIZE replaces each original image with a new one of the given maximum dimension (width or height, depending on the orientation), 760 pixels by default, which is about normal for most Web browsers. In this case, the script has HTML display the images without further scaling (since browser scaling tends produce jaggies and otherwise degrade the image). However, the originals are preserved and linked to from each image page, so you can still see them full size.
Thus for each original image, xxx.jpg, this script can produce:
xxx-t.jpg - The corresponding thumbnail
xxx-r.jpg - The corresponding resized image
The original image is unchanged and keeps its original name.
rename /lower *.*
The photoalbum script itself could also be made to accommodate different casings of JPG, JPEG, and GIF, using a pattern like:
which matches jpg, JPG, Jpg, JpG, jpeg, GIF, Gif, etc etc. This is not a concern in Windows, where filenames are case-insensitive.*.{[jJ][pP][gG],[jJ][pP][eE][gG],[gG][iI][fF]}
- photoalbum
- (no options) Creates a web site titled 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.
- photoalbum height=64 resize
- Creates a web site with all the defaults, except original images are resized to 760 and thumbnails will be 64 pixels high.
After you have created your website, you can go back and edit the pages to add explanatory text. But 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.
K-95> take photoalbum.ksc "title=Antarctica 2006" height=80
(Specify the full path of photoalbum.ksc if necessary.) You'll get lots of error messages about "\fpictureinfo(): no such function" but it will still create a little website with fully functional links. CLICK HERE to see how to run the script "directly" in Windows.