Friday, June 5, 2009

Merging Photo Albums with exiv2

More often than not I take a camera (a Canon Powershot A620 that I purchased a few years ago) to family events and take pictures.

To be honest, my camera is better than I am at taking pictures. I usually set the camera on AUTO, aim, half-press the button until I hear a beep and see the green rectangles around the people or stuff that I'm trying to capture, and then shoot. People around me are usually aware that I'm taking their pictures (I guess it's because I ask them to smile and stand still). I'm pretty happy with the results, most of the time.

My wife's dad has a similar approach to family events, but, unlike me, takes photography seriously. He took lessons, he purchased a professional looking camera (namely, Canon Digital Rebel XTi), and is always futzing around with its settings. He tries to blend in, and conceal the fact that he's taking pictures, in an attempt to capture people in their natural state. He's actually quite good at it.

The other difference between us, is that I usually post my pictures on our self-hosted Gallery2 website. I often pester him to send me a CD with the photos so that I can post them too. I take care of quantity, and he takes care of quality.

And here's where I find myself in a need. I like to order the photos in a chronological order on the website. It's rather easy with photos originating from the same camera, because the file name used for each picture contains a serial number, so that sorting them by name is equivalent to chronological ordering. But the numbering of photos from the other camera is, naturally, not synchronized with my own photos.

The first time I hit this, I tried to order the photos in Gallery2 using the time-stamp that's embedded in each photo's EXIF meta-data. But I found out that the internal clocks of the cameras were not synchronized (one of them was still an hour off, on daylight savings time). So I fixed this with exiv2 by running:
exiv2 -v -a 1:06 adjust my_pics_*.jpg
(yeah, a bit more than an hour - the offset was determined by visually matching the photos and subtracting timestamps of corresponding photos from different sessions).

But this didn't get the photos ordered on Gallery2. I tried setting the file creation time to match the EXIF timestamp:
exiv2 -v -T rename *.jpg
but Gallery2 either sorts by name only or rounds the timestamp to the nearest minute. Whatever the reason, I still couldn't get the photos ordered to my liking. I finally renamed all the files so that each file's name matches its timestamp:
exiv2 -v -t rename *.jpg
which, finally, did the trick.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.