Index: src/com/drew/metadata/exif/ExifReader.java
===================================================================
--- src/com/drew/metadata/exif/ExifReader.java	(revision 6207)
+++ src/com/drew/metadata/exif/ExifReader.java	(working copy)
@@ -20,6 +20,9 @@
  */
 package com.drew.metadata.exif;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import com.drew.lang.BufferBoundsException;
 import com.drew.lang.BufferReader;
 import com.drew.lang.Rational;
@@ -28,9 +31,6 @@
 import com.drew.metadata.Metadata;
 import com.drew.metadata.MetadataReader;
 
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * Decodes Exif binary data, populating a {@link Metadata} object with tag values in {@link ExifSubIFDDirectory},
  * {@link ExifThumbnailDirectory}, {@link ExifInteropDirectory}, {@link GpsDirectory} and one of the many camera makernote directories.
@@ -233,7 +233,7 @@
                 // This error suggests that we are processing at an incorrect index and will generate
                 // rubbish until we go out of bounds (which may be a while).  Exit now.
                 directory.addError("Invalid TIFF tag format code: " + formatCode);
-                return;
+                continue; // JOSM patch to fix #8895#comment:28
             }
 
             // 4 bytes dictate the number of components in this tag's data
Index: src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
===================================================================
--- src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java	(revision 6207)
+++ src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java	(working copy)
@@ -541,7 +541,7 @@
         }
 
         try {
-            double ele=dirGps.getDouble(GpsDirectory.TAG_GPS_ALTITUDE);
+            double ele = dirGps.getDouble(GpsDirectory.TAG_GPS_ALTITUDE);
             int d = dirGps.getInt(GpsDirectory.TAG_GPS_ALTITUDE_REF);
             if (d == 1) {
                 ele *= -1;
@@ -551,53 +551,8 @@
         }
 
         try {
-            // longitude
-
-            Rational[] components = dirGps.getRationalArray(GpsDirectory.TAG_GPS_LONGITUDE);
-            if (components != null) {
-                deg = components[0].doubleValue();
-                min = components[1].doubleValue();
-                sec = components[2].doubleValue();
-
-                if (Double.isNaN(deg) && Double.isNaN(min) && Double.isNaN(sec))
-                    throw new IllegalArgumentException();
-
-                lon = (Double.isNaN(deg) ? 0 : deg + (Double.isNaN(min) ? 0 : (min / 60)) + (Double.isNaN(sec) ? 0 : (sec / 3600)));
-
-                if (dirGps.getString(GpsDirectory.TAG_GPS_LONGITUDE_REF).charAt(0) == 'W') {
-                    lon = -lon;
-                }
-            } else {
-                // Try to read lon/lat as double value (Nonstandard, created by some cameras -> #5220)
-                lon = dirGps.getDouble(GpsDirectory.TAG_GPS_LONGITUDE);
-            }
-
-            // latitude
-
-            components = dirGps.getRationalArray(GpsDirectory.TAG_GPS_LATITUDE);
-            if (components != null) {
-                deg = components[0].doubleValue();
-                min = components[1].doubleValue();
-                sec = components[2].doubleValue();
-
-                if (Double.isNaN(deg) && Double.isNaN(min) && Double.isNaN(sec))
-                    throw new IllegalArgumentException();
-
-                lat = (Double.isNaN(deg) ? 0 : deg + (Double.isNaN(min) ? 0 : (min / 60)) + (Double.isNaN(sec) ? 0 : (sec / 3600)));
-
-                if (Double.isNaN(lat))
-                    throw new IllegalArgumentException();
-
-                if (dirGps.getString(GpsDirectory.TAG_GPS_LATITUDE_REF).charAt(0) == 'S') {
-                    lat = -lat;
-                }
-            } else {
-                lat = dirGps.getDouble(GpsDirectory.TAG_GPS_LATITUDE);
-            }
-
-            // Store values
-
-            e.setExifCoor(new LatLon(lat, lon));
+            LatLon latlon = ExifReader.readLatLon(dirGps);
+            e.setExifCoor(latlon);
             e.setPos(e.getExifCoor());
 
         } catch (Exception ex) { // (other exceptions, e.g. #5271)
Index: src/org/openstreetmap/josm/tools/ExifReader.java
===================================================================
--- src/org/openstreetmap/josm/tools/ExifReader.java	(revision 6207)
+++ src/org/openstreetmap/josm/tools/ExifReader.java	(working copy)
@@ -6,22 +6,33 @@
 import java.text.ParseException;
 import java.util.Date;
 
+import org.openstreetmap.josm.data.coor.LatLon;
+
 import com.drew.imaging.jpeg.JpegMetadataReader;
 import com.drew.imaging.jpeg.JpegProcessingException;
+import com.drew.lang.Rational;
 import com.drew.metadata.Directory;
 import com.drew.metadata.Metadata;
 import com.drew.metadata.MetadataException;
 import com.drew.metadata.Tag;
 import com.drew.metadata.exif.ExifIFD0Directory;
 import com.drew.metadata.exif.ExifSubIFDDirectory;
+import com.drew.metadata.exif.GpsDirectory;
 
 /**
- * Read out exif file information from a jpeg file
+ * Read out EXIF information from a JPEG file
  * @author Imi
+ * @since 99
  */
 public class ExifReader {
 
-    @SuppressWarnings("unchecked") public static Date readTime(File filename) throws ParseException {
+    /**
+     * Returns the date/time from the given JPEG file.
+     * @param filename The JPEG file to read
+     * @return The date/time read in the EXIF section, or {@code null} if not found
+     * @throws ParseException if {@link DateParser#parse} fails to parse date/time
+     */
+    public static Date readTime(File filename) throws ParseException {
         try {
             Metadata metadata = JpegMetadataReader.readMetadata(filename);
             String dateStr = null;
@@ -50,7 +61,22 @@
         return null;
     }
 
-    public static Integer readOrientation(File filename) throws ParseException {
+    /**
+     * Returns the image orientation of the given JPEG file.
+     * @param filename The JPEG file to read
+     * @return The image orientation as an {@code int}. Default value is 1. Possible values are listed in EXIF spec as follows:<br>
+     * <ul>1. The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.</ul>
+     * <ul>2. The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.</ul>
+     * <ul>3. The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.</ul>
+     * <ul>4. The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.</ul>
+     * <ul>5. The 0th row is the visual left-hand side of the image, and the 0th column is the visual top.</ul>
+     * <ul>6. The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.</ul>
+     * <ul>7. The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.</ul>
+     * <ul>8. The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.</ul>
+     * @see <a href="http://www.impulseadventure.com/photo/exif-orientation.html">http://www.impulseadventure.com/photo/exif-orientation.html</a>
+     * @see <a href="http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto">http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto</a>
+     */
+    public static Integer readOrientation(File filename) {
         Integer orientation = null;
         try {
             final Metadata metadata = JpegMetadataReader.readMetadata(filename);
@@ -66,4 +92,65 @@
         return orientation;
     }
 
+    /**
+     * Returns the geolocation of the given JPEG file.
+     * @param filename The JPEG file to read
+     * @return The lat/lon read in the EXIF section, or {@code null} if not found
+     * @since 6209
+     */
+    public static LatLon readLatLon(File filename) {
+        LatLon latlon = null;
+        try {
+            final Metadata metadata = JpegMetadataReader.readMetadata(filename);
+            final GpsDirectory dirGps = metadata.getDirectory(GpsDirectory.class);
+            return readLatLon(dirGps);
+        } catch (JpegProcessingException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (MetadataException e) {
+            e.printStackTrace();
+        }
+        return latlon;
+    }
+
+    /**
+     * Returns the geolocation of the given EXIF GPS directory.
+     * @param dirGps The EXIF GPS directory
+     * @return The lat/lon read in the EXIF section, or {@code null} if {@code dirGps} is null
+     * @throws MetadataException 
+     * @since 6209
+     */
+    public static LatLon readLatLon(GpsDirectory dirGps) throws MetadataException {
+        LatLon latlon = null;
+        if (dirGps != null) {
+            double lat = readAxis(dirGps, GpsDirectory.TAG_GPS_LATITUDE, GpsDirectory.TAG_GPS_LATITUDE_REF, 'S');
+            double lon = readAxis(dirGps, GpsDirectory.TAG_GPS_LONGITUDE, GpsDirectory.TAG_GPS_LONGITUDE_REF, 'W');
+            latlon = new LatLon(lat, lon);
+        }
+        return latlon;
+    }
+
+    private static double readAxis(GpsDirectory dirGps, int gpsTag, int gpsTagRef, char cRef) throws MetadataException  {
+        double value;
+        Rational[] components = dirGps.getRationalArray(gpsTag);
+        if (components != null) {
+            double deg = components[0].doubleValue();
+            double min = components[1].doubleValue();
+            double sec = components[2].doubleValue();
+   
+            if (Double.isNaN(deg) && Double.isNaN(min) && Double.isNaN(sec))
+                throw new IllegalArgumentException();
+   
+            value = (Double.isNaN(deg) ? 0 : deg + (Double.isNaN(min) ? 0 : (min / 60)) + (Double.isNaN(sec) ? 0 : (sec / 3600)));
+   
+            if (dirGps.getString(gpsTagRef).charAt(0) == cRef) {
+                value = -value;
+            }
+        } else {
+            // Try to read lon/lat as double value (Nonstandard, created by some cameras -> #5220)
+            value = dirGps.getDouble(gpsTag);
+        }
+        return value;
+    }
 }
Index: test/unit/org/openstreetmap/josm/tools/ExifReaderTest.java
===================================================================
--- test/unit/org/openstreetmap/josm/tools/ExifReaderTest.java	(revision 0)
+++ test/unit/org/openstreetmap/josm/tools/ExifReaderTest.java	(working copy)
@@ -0,0 +1,61 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.tools;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.text.ParseException;
+import java.util.Date;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openstreetmap.josm.data.coor.LatLon;
+
+/**
+ * EXIF metadata extraction test
+ * @since 6209
+ */
+public class ExifReaderTest {
+
+    private File sampleFile;
+    
+    /**
+     * Setup test
+     * @throws Exception
+     */
+    @Before
+    public void setUp() throws Exception {
+        sampleFile = new File("data_nodist/exif-direction-example.jpg");
+    }
+
+    /** 
+     * Test time extraction
+     * @throws ParseException 
+     */
+    @Test
+    public void testReadTime() throws ParseException {
+        Date date = ExifReader.readTime(sampleFile);
+        assertNotNull(date);
+        System.out.println(date);
+    }
+
+    /**
+     * Test orientation extraction
+     */
+    @Test
+    public void testReadOrientation() {
+        Integer orientation = ExifReader.readOrientation(sampleFile);
+        assertNotNull(orientation);
+        System.out.println(orientation);
+    }
+    
+    /**
+     * Test coordinates extraction
+     */
+    @Test
+    public void testReadLatLon() {
+        LatLon latlon = ExifReader.readLatLon(sampleFile);
+        assertNotNull(latlon);
+        System.out.println(latlon);
+    }
+}
