On April 18 I went on a hiking and geocaching day trip. I used my iPhone to take pictures. I expected the photos to be tagged with the location they were taken, using the GPS built into the iPhone, and that I would be able to import these geotagged photos into the Garmin BaseCamp application. Eventually the photos would be linked to maps on this blog, though I haven’t figured out how to do that yet. This post is about what I discovered about geotagging photos taken by the iPhone; there will be another post about the day trip.
I have a knack for making things much harder than they ought to be. Uploading pictures to iPhoto was easy, and I spent some time cropping and editing them. Then I uploaded the day’s tracks from the Garmin GPS 76C receiver to BaseCamp and spent some time joining and splitting tracks into the segments I wanted. This also was straightforward. Now it was time to import the pictures. I exported the photos from iPhoto and imported them into BaseCamp. BaseCamp did not recognize the photos as being geotagged!
Geotag Detective Story
One reason I write these posts is that I find technical instructions often assume a level of knowledge on the part of the reader that is not there. Often it is the very most basic information that is missing. I found that to be the case when researching the relationship between photos geotagged by iPhone and the inability of BaseCamp to recognize those geotags.
The first thing I did was to go back to iPhoto to try to find the location data for the photos. Of course I was unable to find it. Turns out I’m using iPhoto ’08 and iPhoto ’09 is the first version to recognize location tags. iPhoto ’09 is only available as part of iLife ’09 suite. I don’t use the other parts of iLife enough to warrant purchasing the whole suite just to upgrade iPhoto. (I understand that Picasa understands photo geotags, but all my pictures are in iPhoto and I’m not ready to change just yet.)
BaseCamp has the ability to geotag digital photos by comparing the time tag of the photo to a track file. This actually works pretty well. I used this capability to geotag the iPhone photos by comparing with the tracks from the GPS 76C. Once BaseCamp had geotagged the picture files, it was able to import them. However, I was not satisfied — the iPhone is supposed to geotag the pictures it takes and I wanted to know why it apparently was not doing so.
A Google search turned up very little about geotagging on the iPhone. All you have to do is turn on Location Services and all photos will automatically be geotagged. I had Location Services turned on, but apparently no geotags.
During my hike, I had regularly turned off the iPhone display when not taking pictures. Maybe the iPhone did not have time to lock onto the GPS satellites before I took a picture, so it did not geotag the photos because it did not know where it was? (There was no cell service, so GPS was the only way to get a location.) To test this I brought up the Map app and almost immediately got the little blue pulsing pin showing my location, showing that Location Services knew the location of the iPhone. (I was actually quite impressed that my actual location showed up. This was indoors and the GPS signals would have had to come in through the windows. When Location Services has to use non-GPS data, like cell tower triangulation, it puts my location about 5 miles away.) I snapped a picture of my desk, uploaded to iPhoto, exported to a file, imported to BaseCamp. It was not recognized as a geotagged photo.
Some more googling turned up that perhaps exporting the JPG from iPhoto does not include the location data, especially since my version of iPhoto does not know about locations. Dragging the photo from the library to the hard drive is supposed to solve that. Nope. Did not work.
More googling. People are very sure that the iPhone does indeed geotag photos, but various desktop applications don’t recognize the tags. Some people email their photos directly from the iPhone to Flickr. So I emailed my photo to myself, saved it to a file, and imported into BaseCamp, thus skipping iPhoto and any problems it might have altogether. Still no success; BaseCamp does not recognize that this is a geotagged photo. The problem could be with BaseCamp (though it imports other geotagged photos properly) or with the iPhone (though no one has reported this problem online). I don’t have a second application that recognizes geotags with which to do a comparison. (Actually, Preview displays geotags, but I did not realize it at the time.)
More googling, this time concentrating on BaseCamp rather than iPhone. Finally I hit pay dirt with this forum post:
The key information that is missing from your photo is the GPSVersionID. BaseCamp looks for the GPSVersionID to see if a geotag is present, and in your photo it doesn’t find it so it doesn’t look any further.
This same forum thread made a passing reference to ExifTool, so I looked it up. ExifTool is one of those wonderful open source tools authors make available to everyone at no charge. Here’s the description from the tool’s home page.
ExifTool is a platform-independent Perl library plus a command-line application for reading, writing and editing meta information in a wide variety of files. ExifTool supports many different metadata formats including EXIF, GPS, IPTC, XMP, JFIF, GeoTIFF, ICC Profile, Photoshop IRB, FlashPix, AFCP and ID3, as well as the maker notes of many digital cameras by Canon, Casio, FujiFilm, HP, JVC/Victor, Kodak, Leaf, Minolta/Konica-Minolta, Nikon, Olympus/Epson, Panasonic/Leica, Pentax/Asahi, Ricoh, Samsung, Sanyo, Sigma/Foveon and Sony.
Downloading and installing ExifTool was a snap. It has a command-line interface, but I have a passing familiarity with Unix so using Terminal didn’t faze me. Looking at my test photo that I emailed directly from the iPhone I see that it is indeed geotagged, and that it is missing the GPSVersionID tag.
GPS Latitude Ref : North GPS Longitude Ref : West GPS Altitude Ref : Above Sea Level GPS Time Stamp : 20:54:55.64 GPS Dilution Of Precision : 5 GPS Altitude : 1490 m Above Sea Level GPS Latitude : 35 deg 14' 37.20" N GPS Longitude : 106 deg 37' 54.60" W GPS Position : 35 deg 14' 37.20" N, 106 deg 37' 54.60" W
Next step was to see whether BaseCamp would recognize the geotags in the photo if I added the GPSVersionID tag. The GPSVersionID tag must be in a specific format — I got a hint in this forum post. I was able to use ExifTool to add the GPSVersionID tag to a geotagged photo. BaseCamp then recognized the geotags and imported the photo at a specific location. YAY!! My inner geek is pleased!
While writing this post, I reviewed the research and found hints that Preview recognizes location data. Sure enough, you can Show Inspector from the Tools menu to pop up a small More Info window that shows metadata about the photo. There’s a tab that shows GPS metadata. When looking at the photo to which I had added the GPSVersionID tag, the GPS Version was shown. Otherwise GPS Version did not appear. This is a nicer way of checking the metadata tags than ExifTool, as you can see the photo and metadata at the same time, plus it uses a GUI for navigation. But you can’t modify the file like you can with ExifTool.
Summary – What I Learned About Geotags
- Metadata refers to information about an object, such as a JPG image, as opposed to the object itself. The object might be an image of a flower. Metadata could include the size of the image, the f-stop of the camera taking the picture, and the location where the picture was taken.
- Embedding metadata in a JPG file is evidently quite complex. See this post by Phil Harvey to get an appreciation of the complexity.
- Metadata is identified by tag names. There are thousands of tag names.
- Location metadata is identified by tag names that start with GPS. The GPSVersionID tag is one of these.
- The GPSVersionID tag has the format n.n.n.n, for example, 188.8.131.52. However, BaseCamp writes the tag as .. and this seems to work.
- The camera built in to the iPhone 3G with OS 3.0 does geotag photos, but does not include the GPSVersionID tag, which is needed by some applications like Garmin BaseCamp.
- Geotagging is enabled by turning on Location Services under Settings/General. That’s it — no dialogs, no warnings, not even a status indicator in the Camera app to tell you that photos are being geotagged.
- iPhoto ’08 does not know about geotags. iPhoto ’09 is the first version to recognize location data.
- iPhoto ’08 exports metadata, including geotags, with photos, even though it does not recognize the geotags.
- Preview displays some metadata in the Inspector window. Bring up the Inspector window from Tools/Show Inspector.
- Available categories of metadata are
- General – information about the image, such as size in pixels and color profile.
- Exif – information about the camera and and settings when taking the photo, such as fNumber and exposure mode.
- GPS – location data about the image, such as latitude, longitude, altitude.
- TIFF – information related to TIFF image format, such as orientation and resolution.
- Preview will show the GPSVersionID tag if it exists.
Garmin BaseCamp 184.108.40.206
- BaseCamp will import geotagged photos and locate them on its map.
- BaseCamp looks for the GPSVersionID tag to determine whether the photo is geotagged. If it does not find the GPSVersionID tag, it stops looking, even if the location tags are embedded. This means BaseCamp does not recognize photos from the iPhone as being geotagged because of the missing GPSVersionID tag.
- BaseCamp can geotag photos by comparing the photo timestamp with a GPS track log. The photo is located at the location in the track log that has a timestamp nearest to the timestamp of the photo.
- ExifTool is a free tool that reads and writes metadata in a variety of file formats. It is available for Mac OS X, Windows, and Unix systems. ExifTool is written in Perl.
- On the Mac, ExifTool uses a command-line interface from within Terminal. There is no GUI. The tool’s home page states there is a GUI for Windows.
- I found ExifTool to be easy to install and to use. ExifTool displayed all the metadata contained within the JPG image files I was working with.
- It was easy to add the missing GPSVersionID tag. ExifTool caught my attempts to write the tag in an invalid format. It automatically creates a backup copy of the file being modified to allow recovery if a mistake is made.
- ExifTool can do a lot of stuff with metadata that I haven’t tried. Not only can it geotag photos from a track log, it can also create a track log from geotagged photos! How cool is that?