The gpsdings JNI library

Via the gpsdings JNI library, gpsdings exifloc -e can directly use the C++ library libexiv2 to write gps exif information to digital photographs. When you use the exiv2 (or exiftool) standalone executable a new system process is started for each image. In constrast, gpsdingsjni/libexiv2 stays in memory once loaded, and the overhead of creating a new process for each image is avoided. Therefore, in theory, gpsdingsjni/libexiv2 should be faster than the exiv2 executable. However, when the image files are large, disk I/O may come to dominate the processing time so that the speed advantage of gpsdingsjni/libexiv2 over standalone exiv2 becomes minimal (see timing results below).



There are binaries of the library for Linux and Windows on the download page. The binaries provided have been built using gcc 3.4.4 under Cygwin and gcc 4.0.2 20050901 (prerelease) under SUSE Linux. Put the library file suitable for your platform into the same directory as gpsdings.jar.

Building from source

  1. Download the GPSdings jni sources with
    svn export
    and cd to the jni directory.
  2. Download the exiv2 source tarball, unpack it, and build it:
    tar xvzf exiv2-0.23.tar.gz
    cd exiv2-0.23
    ./configure --disable-xmp --without-zlib --disable-nls
    cd ..
    On Cygwin, you must do
    export CXXFLAGS=-mno-cygwin
    export CFLAGS=-mno-cygwin
    before calling ./configure. I also had to manually edit config.h changing the line
    #define HAVE_SYS_MMAN_H 1
    #undef HAVE_SYS_MMAN_H
    on Cygwin.
  3. Install a java sdk if necessary in order to obtain the jni header files.
  4. Compile JNIExiv2.cpp from the gpsdingsjni source package. With
    you can use the provided build scripts (build.xml with or You may have to change the locations of the JNI headers, the exiv2 headers (<exiv2dir>/src) as well as the exiv2 library location (<exiv2dir>/src/.libs/libexiv2.a). The build target <gpsdingsjni> must be called gpsdingsjni.dll on Windows and on Unix.
  5. Copy <gpsdingsjni> to the directory containing the gpsdings.jar file.

Using it

You are ready to use gpsdingsjni/libexiv2 with exifloc. If you copied to your library path or to the directory where gpsdings.jar resides you can use exifloc -e without argument. Otherwise you need to specify the path to the library file.

Timing results for exifloc -e/-E

Small images

Several test runs on 52 images around 20 K in size gave the following exif write times per image (in seconds).

optionRun 1Run 2Run 3
-e exiv2.exe0.03600.02540.0243
-e gpsdingsjni.dll0.009680.008280.00768
-e exiftool.exe1.0761.0761.088

The pure Java -E is fastest. gpsdingsjni/libexiv2 is just a bit slower. exiv2.exe is significantly slower, but still pretty fast in absolute terms. exiftool is very slow.

Large images

Several test runs on 96 images between 1000 K and 4500 K in size gave the following exif write times per image (in seconds).

optionRun 1Run 2Run 3Run 4
-e exiv2.exe0.4340.4680.413-
-e gpsdingsjni.dll0.4730.3840.4250.535
-e exiftool.exe1.172---

Here, disk I/O speed is the limiting factor for all exif writers except exiftool, which is still two to three times slower than the others.