Index: libgthumb/image-loader.c
===================================================================
RCS file: /cvs/gnome/gthumb/libgthumb/image-loader.c,v
retrieving revision 1.27
diff -u -p -r1.27 image-loader.c
--- libgthumb/image-loader.c	17 Aug 2006 16:16:45 -0000	1.27
+++ libgthumb/image-loader.c	3 Oct 2006 09:16:26 -0000
@@ -37,6 +37,8 @@
 #include "gthumb-marshal.h"
 #include "file-utils.h"
 #include "glib-utils.h"
+#include "gth-exif-utils.h"
+#include "pixbuf-utils.h"
 
 
 #define REFRESH_RATE 5
@@ -410,12 +412,20 @@ static void 
 image_loader_sync_pixbuf (ImageLoader *il)
 {
 	GdkPixbuf              *pixbuf;
+	GdkPixbuf              *temp;
 	ImageLoaderPrivateData *priv;
+#ifdef HAVE_LIBEXIF        
+	GthExifOrientation     orientation;
+#endif
   
 	g_return_if_fail (il != NULL);
      
 	priv = il->priv;
 
+#ifdef HAVE_LIBEXIF        
+	orientation = get_exif_tag_short (image_loader_get_path(il), EXIF_TAG_ORIENTATION);
+#endif
+
 	g_mutex_lock (priv->yes_or_no);
 
 	if (priv->animation == NULL) {
@@ -426,7 +436,48 @@ image_loader_sync_pixbuf (ImageLoader *i
 		return;
 	}
 
+#ifdef HAVE_LIBEXIF
+	temp = gdk_pixbuf_animation_get_static_image (priv->animation);
+
+	switch (orientation) {
+	case GTH_EXIF_ORIENTATION_TOP_LEFT:
+		pixbuf = temp;
+		break;
+	case GTH_EXIF_ORIENTATION_TOP_RIGHT:
+		pixbuf = _gdk_pixbuf_copy_mirror (temp, TRUE, FALSE);
+		break;
+	case GTH_EXIF_ORIENTATION_BOTTOM_RIGHT:
+		pixbuf = _gdk_pixbuf_copy_mirror (temp, TRUE, TRUE);
+		break;
+	case GTH_EXIF_ORIENTATION_BOTTOM_LEFT:
+		pixbuf = _gdk_pixbuf_copy_mirror (temp, FALSE, TRUE);
+		break;
+	case GTH_EXIF_ORIENTATION_LEFT_TOP:
+		pixbuf = _gdk_pixbuf_copy_rotate_90 (temp, FALSE);
+		g_object_unref (temp);
+		temp = pixbuf;
+		pixbuf = _gdk_pixbuf_copy_mirror (temp, TRUE, FALSE);
+		break;
+	case GTH_EXIF_ORIENTATION_RIGHT_TOP:
+		pixbuf = _gdk_pixbuf_copy_rotate_90 (temp, TRUE);
+		break;
+	case GTH_EXIF_ORIENTATION_RIGHT_BOTTOM:
+		pixbuf = _gdk_pixbuf_copy_rotate_90 (temp, FALSE);
+		g_object_unref (temp);
+		temp = pixbuf;
+		pixbuf = _gdk_pixbuf_copy_mirror (temp, FALSE, TRUE);
+		break;
+	case GTH_EXIF_ORIENTATION_LEFT_BOTTOM:
+		pixbuf = _gdk_pixbuf_copy_rotate_90 (temp, FALSE);
+		break;
+	default:
+		pixbuf = temp;
+		break;
+	}
+#else
 	pixbuf = gdk_pixbuf_animation_get_static_image (priv->animation);
+#endif /* HAVE_LIBEXIF */
+
 	g_object_ref (pixbuf);
 
 	if (priv->pixbuf == pixbuf) {
