Fix iPhone geotagged images for certain geographies

Aug 26, '08 07:30:02AM

Contributed by: monototo@gmail.c

Unfortunately, there's something awry with the way the iPhone's geotagged photos are being handled in OS X. At the moment, whether you import photos through iPhoto, Preview or using Image Capture, at some point the GPS reference may get set to North/West. This is a problem if you don't live in the northwestern hemisphere.

Regardless of whether Apple fixes this, you're still going to have to retag all of your old photos. So tonight, I wrote an AppleScript that automates the process. This script can either be set as the Automatic Task in the ImageCapture utility, or you can drag files onto the script for processing.

Copy and paste the code below into Script Editor, customize for your location, and then save as an application (eg. File Format: Application). I've #commented the code to help you find where to tweak the North/South/East/West variables.

(* This script can either be set as the Automatic Task in the ImageCapture utility or you can drag files onto the script for processing.

FIRST: the script checks each file to see if it's been geotagged (otherwise screenshots and saved images that are in your camera roll end up getting tagged with the coordinates 0,0)
SECOND: it changes the reference data on any images that hold an unwanted compass point (eg. North) to the desired reference points (eg. South & East) *)

on open theFiles
  repeat with aFile in theFiles
    #this next bit searches for files that are inappropriately tagged GPSLatitudeRef = N (eg. North)
    #however, depending on where you are, you may want to change it to search for files tagged West (eg. Ref = W)
    do shell script "if (exiftool -v " & quoted form of POSIX path of aFile & " | grep \"GPSLatitudeRef = N'djamena");
    #Change the =S and =E to the desired compass refernces. (South & East are good for Oceania)
    then exiftool -overwrite_original_in_place -gpslatituderef=S -gpslongituderef=E " & quoted form of POSIX path of aFile & "
    fi"
  end repeat
end open

(* As far as I know this works, however I take no responsibility for any loss/gain of data which results from the use of these 1's and 0's. Please share if you see anyway that this script could be improved. *)
[robg adds: I haven't tested this one.]

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080821073713119