Index: trunk/src/org/openstreetmap/josm/data/gpx/GpxImageEntry.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/gpx/GpxImageEntry.java	(revision 18314)
+++ trunk/src/org/openstreetmap/josm/data/gpx/GpxImageEntry.java	(revision 18315)
@@ -732,5 +732,5 @@
 
         try {
-            if (dirExif != null) {
+            if (dirExif != null && dirExif.containsTag(ExifIFD0Directory.TAG_ORIENTATION)) {
                 setExifOrientation(dirExif.getInt(ExifIFD0Directory.TAG_ORIENTATION));
             }
@@ -740,5 +740,5 @@
 
         try {
-            if (dir != null) {
+            if (dir != null && dir.containsTag(JpegDirectory.TAG_IMAGE_WIDTH) && dir.containsTag(JpegDirectory.TAG_IMAGE_HEIGHT)) {
                 // there are cases where these do not match width and height stored in dirExif
                 setWidth(dir.getInt(JpegDirectory.TAG_IMAGE_WIDTH));
Index: trunk/src/org/openstreetmap/josm/tools/ExifReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/ExifReader.java	(revision 18314)
+++ trunk/src/org/openstreetmap/josm/tools/ExifReader.java	(revision 18315)
@@ -177,5 +177,5 @@
      */
     public static LatLon readLatLon(GpsDirectory dirGps) throws MetadataException {
-        if (dirGps != null && dirGps.getTagCount() > 1) {
+        if (dirGps != null && dirGps.containsTag(GpsDirectory.TAG_LATITUDE) && dirGps.containsTag(GpsDirectory.TAG_LONGITUDE)) {
             double lat = readAxis(dirGps, GpsDirectory.TAG_LATITUDE, GpsDirectory.TAG_LATITUDE_REF, 'S');
             double lon = readAxis(dirGps, GpsDirectory.TAG_LONGITUDE, GpsDirectory.TAG_LONGITUDE_REF, 'W');
@@ -297,11 +297,9 @@
     public static Double readElevation(File filename) {
         try {
-            final Metadata metadata = JpegMetadataReader.readMetadata(filename);
-            final GpsDirectory dirGps = metadata.getFirstDirectoryOfType(GpsDirectory.class);
-            return readElevation(dirGps);
+            return readElevation(JpegMetadataReader.readMetadata(filename).getFirstDirectoryOfType(GpsDirectory.class));
         } catch (JpegProcessingException | IOException e) {
             Logging.error(e);
-        }
-        return null;
+            return null;
+        }
     }
 
