Index: /applications/editors/josm/plugins/photo_geotagging/build.xml
===================================================================
--- /applications/editors/josm/plugins/photo_geotagging/build.xml	(revision 28397)
+++ /applications/editors/josm/plugins/photo_geotagging/build.xml	(revision 28398)
@@ -25,5 +25,5 @@
 
     <!-- enter the SVN commit message -->
-    <property name="commit.message" value="fixed josm bug 5800 - 'Override old backup files?' message window can't get focus"/>
+    <property name="commit.message" value="write elevation to EXIF (see josm #7710)"/>
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
     <property name="plugin.main.version" value="4762"/>
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 28397)
+++ /applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/ExifGPSTagger.java	(revision 28398)
@@ -22,4 +22,5 @@
 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;
@@ -36,16 +37,17 @@
      * @param lon longitude
      * @param gpsTime time in milliseconds
+     * @param ele elevation - can be null if not available
      */
-    public static void setExifGPSTag(File jpegImageFile, File dst, double lat, double lon, long gpsTime) throws IOException {
+    public static void setExifGPSTag(File jpegImageFile, File dst, double lat, double lon, long gpsTime, Double ele) throws IOException {
         try {
-            setExifGPSTagWorker(jpegImageFile, dst, lat, lon, gpsTime);
+            setExifGPSTagWorker(jpegImageFile, dst, lat, lon, gpsTime, ele);
         } catch (ImageReadException ire) {
-            throw new IOException(tr("Read error!"));
+            throw new IOException(tr("Read error: "+ire), ire);
         } catch (ImageWriteException ire2) {
-            throw new IOException(tr("Write error!"));
+            throw new IOException(tr("Write error: "+ire2), ire2);
         }
     }
 
-    public static void setExifGPSTagWorker(File jpegImageFile, File dst, double lat, double lon, long gpsTime) throws IOException,
+    public static void setExifGPSTagWorker(File jpegImageFile, File dst, double lat, double lon, long gpsTime, Double ele) throws IOException,
             ImageReadException, ImageWriteException
     {
@@ -109,4 +111,21 @@
             SanselanFixes.setGPSInDegrees(outputSet, 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);
+
+                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);
+            }
+
             os = new FileOutputStream(dst);
             os = new BufferedOutputStream(os);
Index: /applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/GeotaggingAction.java
===================================================================
--- /applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/GeotaggingAction.java	(revision 28397)
+++ /applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/GeotaggingAction.java	(revision 28398)
@@ -212,5 +212,5 @@
                     chooseFiles(e.getFile());
                     if (canceled) return;
-                    ExifGPSTagger.setExifGPSTag(fileFrom, fileTo, e.getPos().lat(), e.getPos().lon(), e.getGpsTime().getTime());
+                    ExifGPSTagger.setExifGPSTag(fileFrom, fileTo, e.getPos().lat(), e.getPos().lon(), e.getGpsTime().getTime(), e.getElevation());
 
                     if (mTimeMode == MTIME_MODE_GPS) {
