Digital photos and me, Part I
September 16, 2006 at 11:14 PM by Dr. Drang
I’ve been doing a lot of photo taking, organizing, and reviewing lately, mostly at work. Although I’m an engineer, not a photographer, photographs play a large role in the work that I do, and I’ve developed some methods of working with them that might be useful to others. The next few posts here will be dedicated to hints, tips, and dead ends that I’ve run across while trying to develop an efficient way of dealing with photos on the Mac.
Let me say first that I don’t use iPhoto; so if you’re expecting a set of iPhoto tips you should look elsewhere. I tried to go with the flow and use iPhoto when I switched to the Mac last year, but its way of organizing photos and mine are too different for us to have a good working relationship. The biggest problem was iPhoto’s desire to keep everything in a single, monolithic library of images. I know that there are ways around that, and I used them for a while, but it’s clear that iPhoto really wants one library. And since I don’t, we had to part ways.
(I’ve also read that more recent versions of iPhoto are less dogmatic about where the photos are kept and how they are organized. This has tempted me to give it another chance, but so far I haven’t succumbed to that temptation. While there’s always some advantage in doing things the way Apple expects you to, my system works well for me, and I’ve found no compelling reason to switch.)
Project photos at work, whether taken by me or someone else, are kept in various folders in a “Photos” folder in the folder where all the project files are kept. This is perhaps better explained by a screenshot:
(You can click on the image to see a full-sized version. I have, of course, changed the names of my projects to protect the anonymity of my clients.)
As you can see, the folders that hold the photographs, as well as the photographs themselves, are named according to the date on which they were taken. The photos, which come out of the camera with names like “DSCN4357.JPG,” are renamed with a Perl program I wrote called canonize. I wrote about canonize some time ago; it’s been updated a bit to:
- format the file name as
yyyymmdd-nnn.jpg
, whereyyyy
is the year,mm
is the month,dd
is the day of the month, andnnn
is a sequential counter. - search the time field of the photos’ EXIF data to determine the order in which photos were taken.
Here’s the current version of canonize:
#!/usr/bin/perl
use Image::Info qw(image_info);
use Getopt::Std;
$usage = <<USAGE;
canonize: rename photos to reflect the date on which they were taken.
Use the date embedded in the EXIF file. The format for the
file name is yyyymdd-nnn.jpg, where yyyy is the year, mm is
the month, dd is the day, and nnn is the (zero-padded) photo
number for that day.
usage:
canonize [options] file-list
option:
-s num: the starting number for the photos (default: 1)
-h: display this help message
USAGE
getopts('hs:');
$startnumber = $opt_s || 1; # default starting number is 1
if ($opt_h || !@ARGV) { die $usage; }
#initialize the counter and date string
$i = $startnumber;
$lowdate = "19890325"; # can be any date that will certainly be
# before the date the earliest photo was taken
$prevdate = $lowdate;
# Slurp in the file list and create a hash of the time each photo was
# taken, keyed to the file name.
foreach $f (@ARGV) {
$info = image_info($f);
$timetaken{$f} = $info->{DateTimeOriginal}; # works for Canon and Nikon
}
# Go through the list in time-taken order, creating a hash of the new
# name, keyed to the original name.
foreach $f (sort {$timetaken{$a} cmp $timetaken{$b}} keys %timetaken ) {
($photodate, $phototime) = split(" ", $timetaken{$f});
$photodate =~ s/\://g;
if ($photodate ne $prevdate) { # we're into a new day, so
if ($prevdate eq $lowdate) { # our first time thru this loop, so
$i = $startnumber; # set the number to the given value
} else { # we've been thru before, so
$i = 1; # set the number to 1
}
$prevdate = $photodate; # prepare for the next
} else { # we're on the same day, so
$i++; # just increment the number
}
$newname{$f} = sprintf("%s-%03d.jpg", $photodate,$i);
}
# Go through the list, renaming all the files.
foreach $f (keys %newname) {
# print "$f -> $newname{$f}\n";
rename ($f, $newname{$f}) or
print "Couldn't change $f to $newname{$f}\n";
}
Having the file named according to the date on which it was taken is very useful in my business, where equipment changes from day to day and documenting its condition is an important reason for taking the photographs. Yes, there are software packages that will read the EXIF data and tell you the date of a photo, but there’s nothing like knowing when a photo was taken by just glancing at its file name.
Tomorrow: how I review photos quickly without iPhoto.