Storing Photos after a Vacation
Kaddi and me tend to take a lot of photos during our vacations. When we return it always takes me a few hours to just organize them1), even though I automated a few steps already.
Here is what I do:
Download and Rotate
We take photos with two cameras now: a Canon PowerShot S10IS and a Sony DSC-HX5V. Photos need to be downloaded from both cameras into separate directories (sony
and canon
).
After downloading they need to be rotated according to their EXIF tags 2) using jhead3).
The Sony simply mounts as a Mass Storage device:
mv /media/disk-1/DCIM/101MSDCF/* sony/ jhead -autorot sony/*.JPG
The Canon uses Picture Transfer Protocol, so I do downloading with gphoto. I wrote a script to download and rotate in one go:
- fetchpics.sh
#!/bin/sh #The cameras image folder. use '--list-files' to get the name of the image folder FOLDER='/store_00010001/' echo "fetching all files..." gphoto2 --auto-detect --get-all-files --folder $FOLDER echo "Autorotating images..." jhead -autorot *.JPG #exiftran -ai *.JPG echo echo "Deleting images from camera (Abort now if not wanted)" echo -n "Hit enter to continue " read foo gphoto2 --auto-detect --delete-all-files --recurse --folder $FOLDER
Process HDR Images
The Sony camera has built in HDR capabilities, but for the Canon we somtimes use Auto-Bracketing to prepare HDR photos. These need to be processed as described in my blog post HDR Photography made easy.
Stitch Panaoramas
The Sony camera has built in Panorama Stitching as well, but sometimes we take single photographs in the Stitch Assist mode of the Canon camera. These need to be assembled. I usually use a Windows software called AutoStitch which works perfect in Wine.
I really need to invest some time to create a simple one script solution using Open Source tools. Or maybe you have one already? If so, please share in the comments.
Merge Chronological
Now we have two directories with images that quite possibly contain pictures of the same events and locations. The aim is to have them all in one directory in the correct chronological order.
To merge both folders, the EXIF timestamps created by both cameras need to be in sync. Unfortunately the clocks of both cameras never really are in sync when taking the photos, so this has to be fixed after the fact. The Sony camera auto adjusts it's clock to the GPS signal, so it is the more precise one. That means I adjust the timestamps of the Canon photos to match the Sony clock using these steps:
- Photograph the clock of the more precise camera (Sony) with the other camera (Canon)
- Use exiftool to read the EXIF date of that picture and compare it with the photographed time
- Adjust the time of the photos (Canon) to match the clock of the more precise clock (Sony):
# substract 5 minutes and 2 seconds from all dates: exiftool -AllDates-='0:0:0 0:05:02' -overwrite_original canon/*.JPG
Now that both directories of photos have the same time base, they can easily be merged using exiftool:
mkdir out exiftool '-FileName<DateTimeOriginal' -d out/%Y%m%d-%H%M%S-canon%%-c.%%e canon/*.JPG exiftool '-FileName<DateTimeOriginal' -d out/%Y%m%d-%H%M%S-sony%%-c.%%e sony/*.JPG
Images are now located in the out
directory named after their EXIF timestamp and the camera brand.
GeoTag
The Sony camera has it's own GPS, but the Canon doesn't. But I like to have my photos geotagged correctly, so the Canon photos (and the Sony ones where the camera had no fix, yet). Need to be tagged based on our GPS's tracklog.
Our NaviGPS stores tracklogs in NMEA format without relative timeinfo. The absolute time is encoded in the filename. New files are created every 1MB. To convert a NMEA logfile to GPX I use the following little script and GPSBabel:
- nmea2gpx.pl
#!/usr/bin/perl foreach $file (@ARGV){ if($file =~ /(\d\d\d\d)(\d\d)(\d\d)_(\d\d\d\d\d\d)\.txt$/i){ $zda = "\$--ZDA,$4.00,$3,$2,$1,00,00\n"; $gpx = $file; $gpx =~ s/\.txt$/.gpx/i; if(! open(BABEL,"|gpsbabel -i nmea -f - -o gpx -F $gpx") ){ print STDERR "failed to open gpsbabel for $gpx\n"; next; } if(! open(NMEA,"$file") ){ print STDERR "failed to read $file\n"; next; } print BABEL $zda; while(<NMEA>){ print BABEL $_; } close BABEL; close NMEA; }else{ print STDERR "bad filename $file\n"; } }
So first get the tracklogs and convert them to GPX:
mkdir gpx mv /media/disk/*.TXT gpx/ nmea2gpx.pl gpx/*.TXT
Now the images can be tagged by correlating the tracklog timestamps with the photo's EXIF timestamps. But before this works, the time difference between the Camera and the GPS needs to be figured out. Since the Sony is synchronized via GPS and we fixed the dates for the Canon pictures, the timestamps should be perfect already, except for the timezone difference. But for the sake of completeness, let's find the real time diff:
- Take a photo of the GPS clock with the default date camera (sony)
- Use exiftool to read the EXIF date of that picture and compare it with the photographed time
- Calculate the difference between the two times in seconds
In my case the Camera is 2 hours and 2 seconds ahead of GPS's GMT which are 7202 seconds.
Now I can use gpsphoto to tag the images. Optionally you can supply some additional text location tags, too.
for GPX in gpx/*.gpx do gpsPhoto.pl --dir out --gpsfile $GPX --city 'Rome' --country 'Italy' --timeoffset -7202 done
Done
Now you them images in the out
directory can be moved to the RAID system and backuped to external storage.
That's my little procedure, but I'm wondering what you guys do with your photos? Do you more or less? If more, what else do you do for organizing? Do you have any tips on how to automate all this? Please let me know in the comments.