Digital Picture Processing

by Anthony Tonns

When organizing my digital picture collection, I couldn't find a decent program that generated thumbnails, resized images (the raw digital pictures are too high resolution for the average CRT) and present them in a consistent, simple to navigate way. So, I wrote some perl scripts that use ImageMagick and later added the use of the Image::Size perl module.

Here is a sample of the script results.

Not long ago, I found the program Web Album Generator by Mark McIntyre. It is an excellent program for the PC/Win32 platform and I recommend it for those who are scared easily by perl (like my Mom).

If you didn't get the hints before, here are the bare essentials:

The main scripts have 6 variables that need to be tweaked before you start using them.
The variables, tweaked for Win32, are:

my $mogrify="C:\\progra~1\\ImageMagick\\mogrify.exe";
my $copy = "copy";
my $move = "move";
my $dirsep = "\\";
my $ext = "JPG";
my $prev_index = "index.html";
The variables I use under RedHat Linux are:

my $mogrify="/usr/X11R6/bin/mogrify";
my $copy = "cp";
my $move = "mv";
my $dirsep = "/";
my $ext = "JPG";
my $prev_index = "index.html";
Make sure that you use double backslashes (\\) for Win32 paths, as a single backslash (\) will escape the next character and totally screw you up. For UNIX the standard directory seperator is slash (/).

Below is a summary of the scripts my collection:

If you look at the scripts, the don't have the typical "#!/usr/local/bin/perl -w" or equivalent as the first line. That is because Win32 platforms don't provide the shebang syntax, or anything like it. The fallout of all this is:

  1. On UNIX, edit all scripts and add "#!/full/path/to/perl -w" as the first line
    Make sure execute permissions are granted with "chmod +x"

  2. On any platform you can invoke all scripts as show in the syntax examples:
    perl ../

  3. On Win32 only you can associate .pl files with the perl.exe binary as per ActiveState's guidelines

  4. On Win32 only you can run "pl2bat". This will create a script.bat which will invoke perl properly. pl2bat comes with ActiveState perl.
It's your choice. I tend to run things prefixed with perl because I'm used to debugging scripts with the command line args of "perl -w -c".

Also note that it may be non-trivial to install Image::Size on Win32 with ActivePerl (at least it was for me). If you can't get PPM to work, you can just download the PPM zip package.