mkphotodir: Turn a directory of photos into a web page
Overview
I use a digital camera to collect pictures.
After I am back, I dump these photos into a directory, delete the
ones which didn't turn out, turn the rest of the photos into a
web page using this program, and then go back to annotate the web
page so others can make sense of the photos.
Each of the photos is converted to two additional formats. The
first is small enough so that all can be on a single web page.
The second is a reasonable size to fill a browser screen, wrapped in
enough of an HTML page to allow the user to go back and forth through
the mid-sized images. In addition, any HTML text in the same file
name, but with a .wh file type is placed into this page.
The original photo is kept as an image which
hopefully has enough resolution to be used for printing.
See the test page for a quick example of
the raw page before annotation.
Getting started
In order to use this program, you need a few prerequisites:
- Perl 5 of some vintage.
- The Image::Size
module from CPAN. See the contrib/cpr program for help
installing perl modules.
- The webc compiler,
a simple HTML preprocessor.
- The convert program. I think this comes from ImageMagick,
but is often installed on linux systems.
This program looks for a number of files starting with the current
directory, and working it's way up the directory tree. At each level
it also looks in Include and image subdirectories.
If not in any directory there, the program also searches the
/etc/mkphotodir directory.
In this way, you can put the common files in some appropriate place
in your web tree, and then if you need a specialized version, can place
that version closer to the specific application.
The files which are deal with in this fashion are:
- mkph.template.wc --
This is the basic template for what the web page surrounding
the mid-sized photos looks like.
- head.wh --
This is the HTML which goes at the start of all of your image web pages.
- tail.wh --
This is the HTML which goes at the end of all of your image web pages.
- photos.pl --
This is a helper library to augment webc to place photos in
the right place.
- appl.lc --
This is another application specific library which augments
webc. If you have common code you use when writing web
pages, it can go in this file.
- left.gif --
Arrow pointing left.
- right.gif --
Arrow pointing right.
- up.gif --
Arrow pointing up.
To install this program, install all of the prerequisite packages first.
Then type "make install" to install the files in standard place.
Check the Makefile to ensure that these files will go where you want.
At that point, you can go into a directory
with a set of images and type mkphotodir and come out with
a web page.
Note that any local changes you have made to the files in
/etc/mkphotodir/ will not be over written.
Pay attention to see if there were differences noted,
and if so decide how you want to deal with those differences.
If the file head.wh2 exists in the current directory, it is
included after the title is generated. In a similar fashion, if the
file tail.wh2 exists in the current directory, it is included
just before the end of the web page. These files allow a certain
amount of application specific HTML to be included into your web page.
This program normally operates on all of the *.gif and *.jpg
files it finds in the current directory, in sorted order. However, if the
file photo.list exists in the current directory, it is assumed
to have image filenames, one to a line, in the order that the user thinks
is important.
As the individual pages are created for each photo, the program looks
for a file with the same stem as the image file, but with an extension
of .wh. If found, this file is included into the web page.
Command line options
This program understands a number of command line options.
These options are specified at five different levels, to allow
you to control default values.
- The first level is the program defaults themselves. If you
don't override a particular option, then this ensures some
sort of reasonable value.
- System defaults can be stored in /etc/mkphotodir/mkphotodir.rc.
- User defaults can be stored in ~/.mkphotodir.rc.
- Web page defaults can be stored in .mkphotodir.rc.
- Command line parameters provide a final way to specify parameters.
This program understands a number of options:
- --columns=0
You can specify the number of columns to use in the main index
page. If not specified, there are two columns aligned left and
right. If you specify some other number of columns, then you get
a table with a picture in each cell.
- --convert=/path/to/convert
The convert program is part of the ImageMagick package.
The default location is /usr/local/bin/convert.
- --smallx=number
Files smaller than this don't get special thumbnails generated.
When thumbnails are generated, they are scaled to this horizontal
dimension. The default value is 250 pixels.
- --midx=number
This is similar to smallx, but controls the mid-sized photos.
The default value is 600 pixels.
- --output=filename.wc
This specifies the name of the output file.
The default value is index.wc.
It is probably best if this ends in .wc.
- --template=/path/to/directory
This specifies a directory to find the various auxiliary
files used by this package. This directory is used if a
more local version of the file is not found.
- --title=Title of web page
This specifies the title of the web page and defaults to
YOUR TITLE GOES HERE.
You will probably be editing the web page anyway to enter
the text describing the photos, so the default title is your
flag that you have work to do.
- --userhead=text/file/name
This specifies a file of text to be included into the web page
after the first photo, but before the rest of the photos.
This defaults to head.wh2.
- --usertail=text/file/name
This is similar to the userhead, but specifies the file
containing text to put at the end of the web page.
- --verbose
Turn on logging of various sorts so you can see what the program
is doing.
Obtaining the current version (v0.12)
You can get the
full package
for this program.
In order to use this, you will need a copy of tar
and gzip.