Index: docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt
===================================================================
--- docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt	(revision 18086)
+++ docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt	(working copy)
@@ -105,9 +105,12 @@
 
 <SECTION>
 <FILE>util</FILE>
+GdkTransform
 gdk_pixbuf_add_alpha
 gdk_pixbuf_copy_area
 gdk_pixbuf_saturate_and_pixelate
+gdk_pixbuf_transform_orientation_auto
+gdk_pixbuf_transform_orientation
 gdk_pixbuf_fill
 </SECTION>
 
Index: gdk-pixbuf/gdk-pixbuf.c
===================================================================
--- gdk-pixbuf/gdk-pixbuf.c	(revision 18086)
+++ gdk-pixbuf/gdk-pixbuf.c	(working copy)
@@ -593,7 +593,15 @@
  * @key: a nul-terminated string.
  * 
  * Looks up @key in the list of options that may have been attached to the
- * @pixbuf when it was loaded. 
+ * @pixbuf when it was loaded, or that may have been attached by another
+ * function using gdk_pixbuf_set_option().
+ *
+ * For instance, the ANI loader provides "Title" and "Artist" options. 
+ * The ICO, XBM, and XPM loaders provide "x_hot" and "y_hot" hot-spot 
+ * options for cursor definitions. The PNG loader provides the tEXt ancillary
+ * chunk key/value pairs as options. Since 2.12, the TIFF and JPEG loaders
+ * have returned an "orientation" option string that corresponds to the 
+ * embedded TIFF/Exif orientation tag (if present).
  * 
  * Return value: the value associated with @key. This is a nul-terminated 
  * string that should not be freed or %NULL if @key was not found.
Index: gdk-pixbuf/gdk-pixbuf.symbols
===================================================================
--- gdk-pixbuf/gdk-pixbuf.symbols	(revision 18086)
+++ gdk-pixbuf/gdk-pixbuf.symbols	(working copy)
@@ -82,6 +82,8 @@
 gdk_pixbuf_add_alpha
 gdk_pixbuf_copy_area
 gdk_pixbuf_saturate_and_pixelate
+gdk_pixbuf_transform_orientation_auto
+gdk_pixbuf_transform_orientation
 #endif
 #endif
 
Index: gdk-pixbuf/gdk-pixbuf-util.c
===================================================================
--- gdk-pixbuf/gdk-pixbuf-util.c	(revision 18086)
+++ gdk-pixbuf/gdk-pixbuf-util.c	(working copy)
@@ -245,6 +245,123 @@
         }
 }
 
+
+/**
+ * gdk_pixbuf_transform_orientation_auto:
+ * @src: A #GdkPixbuf.
+ *
+ * Takes an existing pixbuf and checks for the presence of an
+ * associated "orientation" option, which may be provided by the 
+ * jpeg loader (which reads the exif orientation tag) or the 
+ * tiff loader (which reads the tiff orientation tag, and
+ * compensates it for the partial transforms performed by 
+ * libtiff). If an orientation option/tag is present, the
+ * appropriate transform will be performed so that the pixbuf
+ * is oriented correctly (using gdk_pixbuf_transform_orientation()).
+ *
+ * Return value: A newly-created pixbuf, or a reference to the
+ * input pixbuf (with an increased reference count).
+ *
+ * Since 2.12.
+ **/
+GdkPixbuf *
+gdk_pixbuf_transform_orientation_auto (GdkPixbuf *src)
+{
+  	const gchar *orientation_string;
+	int          transform = 0;
+	GdkPixbuf   *dest;
+
+	g_return_val_if_fail (src != NULL, NULL);
+
+	/* Read the orientation option associated with the pixbuf */
+	orientation_string = gdk_pixbuf_get_option (src, "orientation");	
+
+	if (!orientation_string) {
+		/* If no orientation option is present, 
+		   return a reference to the input pixbuf */
+		dest = src;
+                g_object_ref (dest);
+	} else {
+		/* Convert the orientation string into an integer */
+		transform = (int) g_ascii_strtoll (orientation_string, NULL, 10);
+		dest = gdk_pixbuf_transform_orientation (src, transform);
+	}
+
+	return dest;
+}
+
+
+/** 
+ * gdk_pixbuf_transform_orientation: 
+ * @src: A #GdkPixbuf.
+ * @transform: A #GdkTransform. 
+ * 
+ * Takes a pixbuf and applies a transform (a combination of
+ * flips and/or rotations) to it. The possible transforms
+ * correspond to the embedded orientation tag values
+ * that are optionally present in TIFF and Exif JPEG files. 
+ * 
+ * If the objective is simply to orient the pixbuf in the
+ * manner specified by the embedded orientation tag, the
+ * gdk_pixbuf_transform_orientation_auto() function should
+ * be used instead (which ultimately calls this function). 
+ * This function more suited for applying additional new
+ * transforms (e.g., for a rotation tool).
+ * 
+ * Return value: A newly-created pixbuf, or a reference to the 
+ * input pixbuf (with an increased reference count). 
+ * 
+ * Since 2.12. 
+ **/
+GdkPixbuf *
+gdk_pixbuf_transform_orientation (GdkPixbuf *src, GdkTransform transform)
+{
+	GdkPixbuf *temp;
+	GdkPixbuf *dest;
+
+	g_return_val_if_fail (src != NULL, NULL);
+
+	/* Apply the actual transforms, which involve rotations and flips. */
+        switch (transform) {
+        case GDK_TRANSFORM_NONE:
+                dest = src;
+                g_object_ref (dest);
+                break;
+        case GDK_TRANSFORM_FLIP_H:
+                dest = gdk_pixbuf_flip (src, TRUE);
+                break;
+        case GDK_TRANSFORM_ROTATE_180:
+                dest = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_UPSIDEDOWN);
+                break;
+        case GDK_TRANSFORM_FLIP_V:
+                dest = gdk_pixbuf_flip (src, FALSE);
+                break;
+        case GDK_TRANSFORM_TRANSPOSE:
+                temp = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_CLOCKWISE);
+                dest = gdk_pixbuf_flip (temp, TRUE);
+                g_object_unref (temp);
+                break;
+        case GDK_TRANSFORM_ROTATE_90:
+                dest = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_CLOCKWISE);
+                break;
+        case GDK_TRANSFORM_TRANSVERSE:
+                temp = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_CLOCKWISE);
+                dest = gdk_pixbuf_flip (temp, FALSE);
+                g_object_unref (temp);
+                break;
+        case GDK_TRANSFORM_ROTATE_270:
+                dest = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE);
+                break;
+        default:
+                dest = src;
+                g_object_ref (dest);
+                break;
+        }
+
+        return dest;
+}
+
+
 #define __GDK_PIXBUF_UTIL_C__
 #include "gdk-pixbuf-aliasdef.c"
 
Index: gdk-pixbuf/gdk-pixbuf-core.h
===================================================================
--- gdk-pixbuf/gdk-pixbuf-core.h	(revision 18086)
+++ gdk-pixbuf/gdk-pixbuf-core.h	(working copy)
@@ -231,7 +231,40 @@
                                        gfloat           saturation,
                                        gboolean         pixelate);
 
+/* Transform an image to agree with its associated orientation option */
+GdkPixbuf *gdk_pixbuf_transform_orientation_auto (GdkPixbuf *src);
 
+/**
+ * GdkTransform:
+ * @GDK_TRANSFORM_NONE: 1, no transformation
+ * @GDK_TRANSFORM_FLIP_H: 2, horizontal flip
+ * @GDK_TRANSFORM_ROTATE_180: 3, 180-degree rotation
+ * @GDK_TRANSFORM_FLIP_V: 4, vertical flip
+ * @GDK_TRANSFORM_TRANSPOSE: 5, transpose across UL-to-LR axis (= rotate_90 + flip_h)
+ * @GDK_TRANSFORM_ROTATE_90: 6, 90-degree clockwise rotation
+ * @GDK_TRANSFORM_TRANSVERSE: 7, transpose across UR-to-LL axis (= rotate_90 + flip_v)
+ * @GDK_TRANSFORM_ROTATE_270: 8, 270-degree clockwise
+ *
+ * The GdkTransform numeric values range from 1 to 8, corresponding to
+ * the valid range of TIFF and Exif JPEG orientation tags. The name 
+ * associated with each numeric value describes the data transformation
+ * required that will allow an embedded orientation tag to be reset to "1" 
+ * without changing the displayed image.
+ **/
+typedef enum {
+        GDK_TRANSFORM_NONE = 1,         /* 1 = no transformation */
+        GDK_TRANSFORM_FLIP_H,           /* 2 = horizontal flip */
+        GDK_TRANSFORM_ROTATE_180,       /* 3 = 180-degree rotation */
+        GDK_TRANSFORM_FLIP_V,           /* 4 = vertical flip */
+        GDK_TRANSFORM_TRANSPOSE,        /* 5 = transpose across UL-to-LR axis (= rotate_90 + flip_h) */
+        GDK_TRANSFORM_ROTATE_90,        /* 6 = 90-degree clockwise rotation */
+        GDK_TRANSFORM_TRANSVERSE,       /* 7 = transpose across UR-to-LL axis (= rotate_90 + flip_v) */
+        GDK_TRANSFORM_ROTATE_270        /* 8 = 270-degree clockwise */
+} GdkTransform;
+
+/* Transform an image using a specified combination of flips / rotations */
+GdkPixbuf *gdk_pixbuf_transform_orientation (GdkPixbuf *src, GdkTransform transform);
+
 G_CONST_RETURN gchar * gdk_pixbuf_get_option (GdkPixbuf   *pixbuf,
                                               const gchar *key);
 
