Image manipulation with perl scripts
To begin with, here are a couple of perl scripts that run on linux machines with perl 5 or better installed. I've found them very useful for processing digital photos: There is one for renaming a directory full of photos and another for resizing, creating thumbnails and annotating photos, all at once. The perl scripts use ImageMagick, which is installed by default in my SuSE 9.0 distribution. You can just execute the ImageMagick commands at the command line. Cool.
To execute any of the scripts:
- Save the files with ".pl" extension instead of ".txt".
- You can edit them with a text editor as needed.
- Put the script in a directory with all the files you want to change (and only the files you want to change).
- Open a terminal window and browse to the target directory
- Type "perl file_name.pl" at the command prompt.
Perl renaming files: The perl script for renaming files is customized for my digital camera, where the files always end in ".JPG", but you can easily change this. When you run it, it will ask for a "base name". This is the beginning of all the file names, which are then followed by a dash and a series of numbers from 1 to 999. For example, instead of "DSC0456.JPG" and "DSC0457.JPG", the files will be named "ireland-001.jpg", "ireland-002.jpg", "ireland-003.jpg",... which helps people searching for photos find the relevant subject matter. The perl script also creates a text file called "base_name-sources.txt" that keeps a record of what picture was changed to what name.
Perl resizing photos (jpegs): The perl script for resizing photos reduces the photo by 40% and places a tagline / watermark on it to identify the source. It also creates a subdirectory called "thumbs" and creates thumbnails that are 12% of the original pictures in it. My originals are 1600x1200 pixels, so the photos are 640x480 and the thumbs are 192x144 pixels. In addition to changing the percentages in the scripts, you can also state an explicit size in the "convert -sample" command, such as "640x480". The default behavior is to keep the original aspect ratio, so you might not get exactly both numbers. To find out what the numbers mean in drawing the round rectangle, look up "man imagemagick" at the command line (spacebar=forward, q=quit).

