Index: trunk/src/org/openstreetmap/josm/tools/ExifReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/ExifReader.java	(revision 7937)
+++ trunk/src/org/openstreetmap/josm/tools/ExifReader.java	(revision 7956)
@@ -21,4 +21,5 @@
 import com.drew.metadata.exif.ExifSubIFDDirectory;
 import com.drew.metadata.exif.GpsDirectory;
+import java.awt.geom.AffineTransform;
 
 /**
@@ -188,3 +189,65 @@
         return value;
     }
+
+    /**
+     * Returns a Transform that fixes the image orientation.
+     *
+     * Only orientation 1, 3, 6 and 8 are supported. Everything else is treated
+     * as 1.
+     * @param orientation the exif-orientation of the image
+     * @param width the original width of the image
+     * @param height the original height of the image
+     * @return a transform that rotates the image, so it is upright
+     */
+    public static AffineTransform getRestoreOrientationTransform(final int orientation, final int width, final int height) {
+        final int q;
+        final double ax, ay;
+        switch (orientation) {
+        case 8:
+            q = -1;
+            ax = width / 2;
+            ay = width / 2;
+            break;
+        case 3:
+            q = 2;
+            ax = width / 2;
+            ay = height / 2;
+            break;
+        case 6:
+            q = 1;
+            ax = height / 2;
+            ay = height / 2;
+            break;
+        default:
+            q = 0;
+            ax = 0;
+            ay = 0;
+        }
+        return AffineTransform.getQuadrantRotateInstance(q, ax, ay);
+    }
+
+    /**
+     * Check, if the given orientation switches width and height of the image.
+     * E.g. 90 degree rotation
+     *
+     * Only orientation 1, 3, 6 and 8 are supported. Everything else is treated
+     * as 1.
+     * @param orientation the exif-orientation of the image
+     * @return true, if it switches width and height
+     */
+    public static boolean orientationSwitchesDimensions(int orientation) {
+        return orientation == 6 || orientation == 8;
+    }
+
+    /**
+     * Check, if the given orientation requires any correction to the image.
+     *
+     * Only orientation 1, 3, 6 and 8 are supported. Everything else is treated
+     * as 1.
+     * @param orientation the exif-orientation of the image
+     * @return true, unless the orientation value is 1 or unsupported.
+     */
+    public static boolean orientationNeedsCorrection(int orientation) {
+        return orientation == 3 || orientation == 6 || orientation == 8;
+    }
 }
