Index: /applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/ExifGPSTagger.java
===================================================================
--- /applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/ExifGPSTagger.java	(revision 30802)
+++ /applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/ExifGPSTagger.java	(revision 30803)
@@ -13,16 +13,15 @@
 import java.util.TimeZone;
 
-import org.apache.sanselan.ImageReadException;
-import org.apache.sanselan.ImageWriteException;
-import org.apache.sanselan.Sanselan;
-import org.apache.sanselan.common.IImageMetadata;
-import org.apache.sanselan.formats.jpeg.JpegImageMetadata;
-import org.apache.sanselan.formats.jpeg.exifRewrite.ExifRewriter;
-import org.apache.sanselan.formats.tiff.TiffImageMetadata;
-import org.apache.sanselan.formats.tiff.constants.GPSTagConstants;
-import org.apache.sanselan.formats.tiff.fieldtypes.FieldType;
-import org.apache.sanselan.formats.tiff.write.TiffOutputDirectory;
-import org.apache.sanselan.formats.tiff.write.TiffOutputField;
-import org.apache.sanselan.formats.tiff.write.TiffOutputSet;
+import org.apache.commons.imaging.ImageReadException;
+import org.apache.commons.imaging.ImageWriteException;
+import org.apache.commons.imaging.Imaging;
+import org.apache.commons.imaging.common.IImageMetadata;
+import org.apache.commons.imaging.common.RationalNumber;
+import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
+import org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter;
+import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
+import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
+import org.apache.commons.imaging.formats.tiff.write.TiffOutputDirectory;
+import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
 
 public class ExifGPSTagger {
@@ -52,5 +51,5 @@
         TiffOutputSet outputSet = null;
 
-        IImageMetadata metadata = Sanselan.getMetadata(jpegImageFile);
+        IImageMetadata metadata = Imaging.getMetadata(jpegImageFile);
         JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
         if (null != jpegMetadata) {
@@ -66,6 +65,9 @@
         }
 
+        TiffOutputDirectory gpsDirectory = outputSet.getOrCreateGPSDirectory();
+        gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_VERSION_ID);
+        gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_VERSION_ID, (byte)2, (byte)3, (byte)0, (byte)0);
+
         Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
-
         calendar.setTimeInMillis(gpsTime);
 
@@ -87,39 +89,26 @@
         //System.err.println("date: "+dateStamp+"  h/m/s: "+hour+"/"+minute+"/"+second);
 
-        Double[] timeStamp = {new Double(hour), new Double(minute), new Double(second)};
-        TiffOutputField gpsTimeStamp = TiffOutputField.create(
-                GPSTagConstants.GPS_TAG_GPS_TIME_STAMP,
-                outputSet.byteOrder, timeStamp);
-        TiffOutputDirectory exifDirectory = outputSet.getOrCreateGPSDirectory();
         // make sure to remove old value if present (this method will
         // not fail if the tag does not exist).
-        exifDirectory.removeField(GPSTagConstants.GPS_TAG_GPS_TIME_STAMP);
-        exifDirectory.add(gpsTimeStamp);
+        gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_TIME_STAMP);
+        gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_TIME_STAMP, 
+                RationalNumber.valueOf(hour),
+                RationalNumber.valueOf(minute),
+                RationalNumber.valueOf(second));
 
-        TiffOutputField gpsDateStamp = SanselanFixes.create(
-                GPSTagConstants.GPS_TAG_GPS_DATE_STAMP,
-                outputSet.byteOrder, dateStamp);
         // make sure to remove old value if present (this method will
         // not fail if the tag does not exist).
-        exifDirectory.removeField(GPSTagConstants.GPS_TAG_GPS_DATE_STAMP);
-        exifDirectory.add(gpsDateStamp);
+        gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_DATE_STAMP);
+        gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_DATE_STAMP, dateStamp);
 
-        SanselanFixes.setGPSInDegrees(outputSet, lon, lat);
+        outputSet.setGPSInDegrees(lon, lat);
 
         if (ele != null) {
             byte eleRef =  ele >= 0 ? (byte) 0 : (byte) 1;
-            TiffOutputField gpsAltitudeRef = new TiffOutputField(
-                    GPSTagConstants.GPS_TAG_GPS_ALTITUDE_REF,
-                    FieldType.FIELD_TYPE_BYTE, 1, new byte[] { eleRef });
-            exifDirectory.removeField(GPSTagConstants.GPS_TAG_GPS_ALTITUDE_REF);
-            exifDirectory.add(gpsAltitudeRef);
+            gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_ALTITUDE_REF);
+            gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_ALTITUDE_REF, eleRef);
 
-            Number[] val = new Number[] { Math.abs(ele) };
-            byte[] bytes = FieldType.FIELD_TYPE_RATIONAL.writeData(val, outputSet.byteOrder);
-            TiffOutputField gpsAltitude = new TiffOutputField(
-                    GPSTagConstants.GPS_TAG_GPS_ALTITUDE,
-                    FieldType.FIELD_TYPE_RATIONAL, 1, bytes);
-            exifDirectory.removeField(GPSTagConstants.GPS_TAG_GPS_ALTITUDE);
-            exifDirectory.add(gpsAltitude);
+            gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_ALTITUDE);
+            gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_ALTITUDE, RationalNumber.valueOf(Math.abs(ele)));
         }
         try (BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(dst))) {
Index: plications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/SanselanFixes.java
===================================================================
--- /applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/SanselanFixes.java	(revision 30802)
+++ 	(revision )
@@ -1,119 +1,0 @@
-// This file contains fixes for some bugs of sanselan.
-// License: Apache Software License, Version 2.0
-package org.openstreetmap.josm.plugins.photo_geotagging;
-
-import org.apache.sanselan.ImageWriteException;
-import org.apache.sanselan.formats.tiff.constants.TagInfo;
-import org.apache.sanselan.formats.tiff.constants.TiffConstants;
-import org.apache.sanselan.formats.tiff.fieldtypes.FieldType;
-import org.apache.sanselan.formats.tiff.write.TiffOutputDirectory;
-import org.apache.sanselan.formats.tiff.write.TiffOutputField;
-import org.apache.sanselan.formats.tiff.write.TiffOutputSet;
-
-public class SanselanFixes implements TiffConstants {
-    /**
-     * The setGPSInDegrees method produces Strings without trailing NULL character.
-     * We simply redirect the create() call to SanselanFixes.create().
-     */
-
-    /**
-     * A convenience method to update GPS values in EXIF metadata.
-     *
-     * @param longitude Longitude in degrees E, negative values are W.
-     * @param latitude latitude in degrees N, negative values are S.
-     * @throws ImageWriteException
-     */
-    public static void setGPSInDegrees(TiffOutputSet outputSet, double longitude, double latitude)
-            throws ImageWriteException
-    {
-        TiffOutputDirectory gpsDirectory = outputSet.getOrCreateGPSDirectory();
-
-        String longitudeRef = longitude < 0 ? "W" : "E";
-        longitude = Math.abs(longitude);
-        String latitudeRef = latitude < 0 ? "S" : "N";
-        latitude = Math.abs(latitude);
-
-        {
-            TiffOutputField longitudeRefField = SanselanFixes.create(
-                    TiffConstants.GPS_TAG_GPS_LONGITUDE_REF, outputSet.byteOrder,
-                    longitudeRef);
-            gpsDirectory.removeField(TiffConstants.GPS_TAG_GPS_LONGITUDE_REF);
-            gpsDirectory.add(longitudeRefField);
-        }
-
-        {
-            TiffOutputField latitudeRefField = SanselanFixes.create(
-                    TiffConstants.GPS_TAG_GPS_LATITUDE_REF, outputSet.byteOrder,
-                    latitudeRef);
-            gpsDirectory.removeField(TiffConstants.GPS_TAG_GPS_LATITUDE_REF);
-            gpsDirectory.add(latitudeRefField);
-        }
-
-        {
-            double value = longitude;
-            double longitudeDegrees = (long) value;
-            value %= 1;
-            value *= 60.0;
-            double longitudeMinutes = (long) value;
-            value %= 1;
-            value *= 60.0;
-            double longitudeSeconds = value;
-            Double values[] = {
-                    new Double(longitudeDegrees), new Double(longitudeMinutes),
-                    new Double(longitudeSeconds),
-            };
-
-            TiffOutputField longitudeField = TiffOutputField.create(
-                    TiffConstants.GPS_TAG_GPS_LONGITUDE, outputSet.byteOrder, values);
-            gpsDirectory.removeField(TiffConstants.GPS_TAG_GPS_LONGITUDE);
-            gpsDirectory.add(longitudeField);
-        }
-
-        {
-            double value = latitude;
-            double latitudeDegrees = (long) value;
-            value %= 1;
-            value *= 60.0;
-            double latitudeMinutes = (long) value;
-            value %= 1;
-            value *= 60.0;
-            double latitudeSeconds = value;
-            Double values[] = {
-                    new Double(latitudeDegrees), new Double(latitudeMinutes),
-                    new Double(latitudeSeconds),
-            };
-
-            TiffOutputField latitudeField = TiffOutputField.create(
-                    TiffConstants.GPS_TAG_GPS_LATITUDE, outputSet.byteOrder, values);
-            gpsDirectory.removeField(TiffConstants.GPS_TAG_GPS_LATITUDE);
-            gpsDirectory.add(latitudeField);
-        }
-
-    }
-
-    /**
-     * fix for 2 Problems:
-     *     - ASII Fields have always length 1
-     *     - Trailing NULL character is missing
-     */
-    public static TiffOutputField create(TagInfo tagInfo, int byteOrder,
-        String value) throws ImageWriteException
-    {
-        FieldType fieldType;
-        if (tagInfo.dataTypes == null)
-            fieldType = FIELD_TYPE_ASCII;
-        else if (tagInfo.dataTypes == FIELD_TYPE_DESCRIPTION_ASCII)
-            fieldType = FIELD_TYPE_ASCII;
-        else
-            throw new ImageWriteException("Tag has unexpected data type.");
-
-        // According to EXIF spec, we need to append a NULL byte.
-        // This way we have the same output as we would get with the exiftools library.
-        String newValue = value+'\0';
-        byte bytes[] = fieldType.writeData(newValue, byteOrder);
-        // the count "1" in the original code (see commented out original)
-        // is wrong as it assumes the field being updated is a single ascii char
-        //return new TiffOutputField(tagInfo.tag, tagInfo, fieldType, 1, bytes);
-        return new TiffOutputField(tagInfo.tag, tagInfo, fieldType, newValue.length(), bytes);
-    }
-}
