Teaching Bibble5 where your photos were taken

When your a lucky one, then your camera is equipped with a GPS sensor and each photo you shoot  is automatically filled with the GPS position where it was taken. Unfortunately such solutions are still rare and quite expensive. This article presents a solution when using Bibble to process your raw photos. There are many tools that do the job for jpg but not for raw digital images.  However adding GPS information to a jpg when the source of this jpg is a raw file from which the jpg can be generated again and again (overwriting all meta information contained in it) is clearly not really effective. The solution presented below is a solution that overcomes the overwriting problem described above since it is applied to the raw files or more excatly to Bibbles xmp files.

Bibble is a professional photo processing tool, that is available for linux, windows and macos.

Introduction

So how can one collect GPS information for photos taken somewhere and assign these data to the correct photos?


A solution is to use some sort of GPS tracking device while you are shooting, and then later to bring the GPS coordinates to your photos by comparing the time in the EXIF data of the photo with the timestamp of waypoints in the GPS track recorded. If both match or are close together then the GPS coordinates of this waypoint is assigned to the photo. For this trick the clock in your camera should of course be set correctly. A GPS track  contains time information in GMT (Greenwich Mean Time) and your cameras clock can be in another timezone (so the hour differs) but the minutes have to be correct else there is no way to find the correct GPS entry for a certain photo later on.


A possible device to record GPS tracks is a mobile phone that has a GPS sensor and to use some sort of GPS tracking application on it. In my article Geotagging von Photos (in german) I described how do exactly this with my mobile a Nokia E55. While you are shooting you have your mobile permanently record GPS information. Afterwards you copy the generated track file from the mobile to your computer and then you assign the matching GPS data to each photo in turn. You can of course use any GPS tracking device you like as long as this device can record GPS information and export it to your computer.

Bibble and GPS data

When shooting Raw digital photos, there is of course one problem: When shooting in raw mode you usually do not want to touch the raw files since they are considered as a digital negatives. Thats just what Bibble does perfectly. It allows you to work on your photos without ever modifying the raw photo files. Instead all your settings (color, whitebalance, levels, sharpening, ...) you make are recorded in a sidecar file having the extension ".xmp" . For each of your raw camera files that you process Bibble creates one xmp file with the same name but the extension .xmp .

The good new is, that this xmp file may also contain information about the GPS position of where the photo has been taken. And if this information is there, then a file eg jpg that Bibble creates for you from the raw data will also contain this GPS information and when looking at the final jpg file you will be able to see where exactly it has been taken.

The only question is: How can you tell Bibble for a series of photos the correct GPS information? Of course you could enter this information manually in Bibbles interface, but this is not a job you would really want to do for say 100 photos.

Assigning GPS data to your photos

The answer to this question is: Use a GPS track recorded eg by your mobile and then take my script gpx2bib and let this script do the real work of finding the correct GPS information in your track for each photo. Beeing more precise, the script will not care about your raw photos and will of course never modify them, instead it will read the xmp file for each photo and enter GPS information from the GPS track into this file if they are found in the track. Because the script processes xmp files, the script can actually supply GPS information to all types of photo files (raw, jpg, ...) that Bibble can edit and create a xmp file for.

Here is what happens exactly:


You have a GPS track file in GPX format that was created eg by a GPS tracking software running eg on your mobile phone or any other GPS tracking device while you were shooting your photos. It is important that the track is stored in a file using the GPX-exchange format. If your tracking device is unable to create GPX, then you can use a converter to convert the internal format of your device to GPX. A well know converter that is capable of coverting allmost any format in any other is gpsbabel.

When your home again from your shooting you process all your photos using Bibble5 and then quit Bibble5. As a result there is a xmp file with your settings for each of the photos.
Now you start  gpx2bib and tell it where to find the GPX track file and which (possibly all) photos (xmp files) to process. The script will then look at each xmp file in turn, read the date of when the photo was taken from the xmp file (Bibble has automatically written this datum in there before, using the EXIF information in the photo) and then it will look through all the entries in the GPS track(s) and try to find the entry that has a recording time that is as near as possible to the shooting time of the photo. You can of course tell the script how many minutes the GPS information and the time in the photo may differ to still be considered "equal".  The default is 15 minutes. If the script finds GPS information that has a time close enough to the time in the photo it will enter the GPS information from the track file into the xmp file. The next time you start Bibble it will read this new information from the xmp file and display the GPS coordinates for each of the photos processed in the Metadata tab. All your settings you made before are of course unchanged. This way you can assign GPS information to a hundreds of photos with just one script call, provided the GPS track contains GPS information for the time when the photos were taken. Another constraint is, that this method onyl works when you are using Bibble in filesystem mode and not use catalogs.

Installation

The script is written in Perl, a script language that works fine on Windows as well as on linux or Macs. When using windows you can eg use Active Perl, a perl compilation that I used to test the script on windows. On linux the regular perl installation should just work. The only thing you have to do no matter if windows or linux is to install some perl modules the script needs:

  • Date::Format
  • Date::Parse
  • XML::Simple
  • File::Basename


If some modules are missing the script will simply fail to run and complain about the missing perl module. Many of these modules are already part of eg Active Perl, the rest can be installed using a module installer. The only module I had to install on my windows 7 system with active perl was DateTime-Format-DateParse, everything else was already on board.

An Example

Here is an example of the script in action running on my linux box. The script is started from a console window in linux or from the command window in Windows. In the console or commando window you should  change directory to the folder where your raw files as well as the corresponding xmp files are stored, and then call the script :

[krienke@robotnik:~/lib/photos/rainer/2010/Aegypten/Raw] 1063 > gpx2bib   --gps-override --tz-offset=-2 --max-dt=30  --gpx ../GPS-Trk/Aegypten.gpx *.xmp
+ Applying timeoffset of -2 to match photos with GPS data
+ Script will override possibly existing old GPS values in xmp file
+ Reading GPX files ..
+ Read file ../GPS-Trk/Aegypten 1.gpx  (7146 pts) ...
+ dsc_7830.nef.xmp (02/05/10 09:16:10) GpxDt: 0min (lon:32.6570644, lat:25.7184865) Ok.
+ dsc_7831.nef.xmp (02/05/10 09:16:52) GpxDt: 0min (lon:32.6569939, lat:25.7186431) Ok.
+ dsc_7832.nef.xmp (02/05/10 09:20:42) GpxDt: 0min (lon:32.6568296, lat:25.7189588) Ok.
+ dsc_7833.nef.xmp (02/05/10 09:21:41) GpxDt: 0min (lon:32.6566428, lat:25.7189922) Ok.
+ dsc_7838.nef.xmp (02/05/10 09:31:35) GpxDt: 5min (lon:32.6557460, lat:25.7197892) Ok.
+ dsc_7839.nef.xmp (02/05/10 09:39:26) GpxDt: 13min (lon:32.6557460, lat:25.7197892) Ok.
- dsc_7840.nef.xmp (02/05/10 11:54:25) deltaT: | 148| > 30 min. Skipped.
- dsc_7842.nef.xmp (02/05/10 12:00:22) deltaT: | 154| > 30 min. Skipped.
- dsc_7843.nef.xmp (02/05/10 12:01:43) deltaT: | 155| > 30 min. Skipped.
+ dsc_7888.nef.xmp (02/05/10 14:12:48) GpxDt: -26min (lon:32.5344979, lat:25.4509318) Ok.
+ dsc_7891.nef.xmp (02/05/10 14:28:59) GpxDt: -10min (lon:32.5344979, lat:25.4509318) Ok.
+ dsc_7893.nef.xmp (02/05/10 14:31:27) GpxDt: -7min (lon:32.5344979, lat:25.4509318) Ok.
+ dsc_7896.nef.xmp (02/05/10 14:36:53) GpxDt: -2min (lon:32.5344979, lat:25.4509318) Ok.

...
...

The script was called with several parameters most of them are optional. The mandatory parameters is --gpx with the path to the GPX file containing GPS track information and a list of xmp files to be processed (*.xmp means process all xmp files in the current directory).  You may specify several --gpx option with different GPX files that are all used to find a matching GPS entry for the photos to be processed.

Script parameters

The optional parameters are:

  • --tz-offset=-2 : Assume that the clock of your camera has an offset of -2 hours compared to theGPS track data which are always in GMT. For my photos the difference is two hours, since I adjusted my cameras clock to local time which is GMT + 2 hours . So I have to subtract 2 hours to adapt the photos time to GMT for the GPX track that contains entries that are always in GMT.
  • --max-dt=30:     Define the maximum difference in minutes (30) between the photos shooting time  and the time in a track point (modified by --tz-offset) so that both are considered matching and the GPS information is entered in the xmp file.
  • --gps-override:  Allow the script to override GPS information that might already exist in some xmp files. Without this option such files are not processed even if the GPX track contains matching GPS information.
  • --test-only:     Not used in the example from above but useful if you just want to check what would be done without actually doing it. The script will not modify anything but tell you what would happen without this option.
  • --no-backup: This option will tell the script not to make any backups of xmp files.
  • --silent: Be less verbose.

In the output you see some lines beginning with "+" which has the meaning, that the script was able to find GPS information for this photo (xmp file). To the right you see the name of the photo (xmp file), the shooting date of this photo, then GpxDt, the difference of the best matching GPS entry from the GPX file to the photos time in minutes , and then the latitude and longitude values found that will be entered into the xmp file.
Then there are lines starting with "-" meaning that the script could not find matching GPS information for this photo with regard to the time value given by --max-dt.  The line does show you how big the minimal difference in time between any GPS entry and the photos shooting time was. This allows you to play around with different --max-dt values using --test-only option for testing around until you got the right settings.

As an extra precaution the script will copy the original xmp files into a subfolder it will create named "xmp.bak/".  The backup of each xmp file  is done only one time, so no matter how often you call the script the xmp.bak folder will contain your original xmp file if anything should go wrong. If you do not want backups you can use option --no-backup .

Bibbles view

When you look at your photos in Bibble5 you can use the metadata tab to see if a photo has GPS information assigned. Here is a screeshot that shows some photos that do not have GPS information. You can click on the screenshot to get a more detailed view in a new browser window:

Photo in Bibble without GPS

After running the script as demonstrated  above the very same photos in Bibble5 look like this screenshot demonstrates:

Photo in bibble with GPS data

The important difference are the entries for longitude (GPS Längengrad) and latitude (GPS Breitengrad) that now have correct GPS position values. If you tell Bibble to create a jpg file from this raw photo, it will also contain the GPS data. Depending on the software you use to look at your jpg photos, you can see a mark on a map when you click on your photo with GPS data.  For myself I use digikam, and the screenshot below shows you digikam main window with one selected photo. On the left side you see a map (here Egypt) and a red mark that depicts the exact location of where the selected photo was taken:

GPS data visualisation in digikam

 

You can download the script here.

If you like the script please donate a small amount to support the project. Thank you very much.

 

R.K.

You have no rights to post comments