$Id: utilities.pod,v 1.4 2002/05/14 04:21:01 tangledhelix Exp $

Bundled Utilities

mkGallery.pl - Create a gallery from images in the current directory.

jhead - Extracts EXIF header information from JPEG files. (jhead is used by mkGallery.pl, so you don't need to use it directly. However, you can if you want to. It has a lot of nice features).

mkGallery.pl

mkGallery.pl can do three things:

1. Take a directory full of images and create thumbnails for them.

2. Read EXIF header information from image files and cache it in text files for Mig to use.

3. Create blank comment templates in mig.cf files.

It can do all of them at the same time, too. It can accept a list of images to work with, or simply process all images in the current directory. It can also recurse directories and do an entire album.

(Note that mkGallery.pl requires Perl. Perl is not required for Mig itself. It is required only to use the mkGallery.pl utility. To generate thumbnails, the convert utility from the ImageMagick suite is also required.)

mkGallery.pl uses the following Perl modules. When I first wrote mkGallery.pl I was using Perl 5.005_03, and these were all included (no extra installations were needed).

    strict
    Cwd
    File::Basename
    File::Find
    Getopt::Std

mkGallery.pl has not been tested under Microsoft Windows to my knowledge.

  Usage:
    mkGallery.pl [ -h ] [ -a ] [ -w ] [ -t ] [ -e ] [ -c ] [ -i ]
        [ -s <size> ] [ -q <quality> ] [ -M <type> ] [ -m <label> ]
        [ -n ] [ -r ] [ -d ] [ -D <dir> ] [ -E <ext> ]
        [ <file1> <file2> <...> ]
      -h : Prints this help message.
      -a : Process all image files in current directory.
      -w : Turn over-write on.  By default, files written such
           as the EXIF file will be appended to rather than
           over-written.  Using "-w" indicates the file should
           be over-written instead.
      -t : Generate thumbnail images.
      -e : Build "exif.inf" file.  You must compile the jhead
           utility (included) before you can use the -e option.
      -c : Generate blank comments for uncommented images.
      -i : "Interactive" mode for comments
      -s : Set pixel size for thumbnails.
      -q : Set quality level for thumbnails.
      -M : Define type of "prefix" or "suffix".
      -m : thumbnail marker label (default "th").
      -n : Only process thumbnails that don't exist (new-only).
           Will also process thumbnails which are older than the
           full-size images they are associated with.
      -r : Recursive mode - process this folder as well as any
           folders and subfolders beneath it.
      -d : Use thumbnail subdirectories (instead of using _th, etc).
      -D : Name of thumbnail subdirectory to use (default is "thumbs" or
           whatever is in your config.php file).
      -E : File extension to use for thumbnails.
    * If creating thumbnails, "convert" must be in your $PATH.
    * This program supports JPEG, PNG and GIF formats.
    * The "-e" feature only supports JPEG files.
      Mig - http://mig.sourceforge.net/

A note about pixel sizes

ImageMagick will be given a geometry of SIZExSIZE where SIZE is the value passed to mkGallery.pl with the -s flag. For instance, specifying -s 250 will give ImageMagick a geometry of 250x250. This means it will create a thumbnail image where the maximum value of height (or the maximum value of width) is 250 pixels. It will not exceed that value for either width or height. However, it will maintain the aspect ratio of the image.

Here are some examples I got from testing using the default setting which is 100.

  Original size     Thumbnail size
    1280 x 960        100 x  75
     505 x 250        100 x  49
     347 x 202        100 x  58
     160 x 205         78 x 100

A note about quality levels

Some image formats such as JPEG can have varying quality levels. The default level is 50 but any value from 1 to 100 is valid. The higher the number, the better the quality of the thumbnail. I have found that 50 is a good number and produces a fairly clear thumbnail from even large detailed photographs yet still keeping a very good file size (usually below 2.5K).

A quality level can be specified with -q number.

Thumbnails

Thumbnails are stored in a subdirectory called thumbs by default. (This can be changed - see the $thumbSubdir option in config.php.)

A thumbnail has the same filename as the full-size image it represents. An image called img_4190.jpg would have a thumbnail file called thumbs/img_4190.jpg.

It is not necessary to create the directories ahead of time - mkGallery.pl will create any directories it needs if they don't already exist.

Interactive mode

When using the -c option to generate comment fields in mig.cf, you can also optionally specify -i or Interactive mode. Basically all this will do is prompt for each image which does not already have a comment, and you can (optionally) type in a comment for that image. If you don't want to do so, just hit Enter and that image will be skipped - mkGallery.pl will move along to the next one in the list.

New-only mode

The new-only mode (-n) basically follows this set of rules.

1. If an image file exists without a thumbnail associated with it, generate a thumbnail for it.

2. If an image file exists, has a thumbnail, but is newer than its thumbnail file, re-generate the thumbnail.

If -n is not specified, a new thumbnail will be generated for every image.

Recursive mode

Recursive mode makes it simple to do large chunks of an album. For example, if a new folder has been added called Travel and there are a total of 17 folders that are located underneath it (as subdirectories, or sub-subdirectories), handling each one would be tedious. It's easier to just go to the top of the tree you want to work on (in this case Travel) and invoke mkGallery.pl with the recursive flag (-r).

New users can simply go to their root (albums) and invoke mkGallery.pl -art, and mkGallery.pl will generate thumbnails for everything in the entire gallery.

Personally I find -rant to be the most useful combination of modes. It's also easy to remember.

Recursive mode works with all of the action modes (-c, -e, -t).

jhead

jhead was written by Matthias Wandel and can be found at:

    http://www.sentex.net/~mwandel/jhead/index.html

It is included here but I take no credit for the code. Matthias however deserves lots of credit for it, as it's incredibly useful! Feel free to drop Matthias a line and let him know his code is appreciated. His email address is available at the URL shown above.

jhead is a C program, and must be compiled before it can be used. On most unix-like systems, that's as easy as going into the jhead directory and typing "make". When make is finished, there should be a jhead file, which you can copy to some other directory for safekeeping.

The makefile for jhead assumes gcc is available. If that's not the case, edit Makefile to point to your compiler. I've successfully built jhead on systems running Linux, FreeBSD, Solaris and Apple OSX.

Windows users should download the pre-built Windows version of jhead available at the URL above.

jhead should be placed in the utilities subdirectory of your Mig installation.

(jhead is not something you need to run directly - it is used by mkGallery.pl if you invoke mkGallery.pl with the -e flag.)