Index: src/catalog-web-exporter.c
===================================================================
RCS file: /cvs/gnome/gthumb/src/catalog-web-exporter.c,v
retrieving revision 1.46
diff -u -p -r1.46 catalog-web-exporter.c
--- src/catalog-web-exporter.c	8 Nov 2006 18:18:33 -0000	1.46
+++ src/catalog-web-exporter.c	15 Nov 2006 13:18:50 -0000
@@ -1754,7 +1754,7 @@ export__save_other_files (CatalogWebExpo
 
 
 static void
-copy_exif_from_orig (const char *src_filename, 
+copy_exif_from_orig_and_reset_orientation (const char *src_filename, 
 		     const char *dest_filename)
 {
 	JPEGData     *jdata_src, *jdata_dest;
@@ -1782,13 +1782,22 @@ copy_exif_from_orig (const char *src_fil
 	if (jdata_dest == NULL)
 		return;
 
-	/* The exif orientation tag, if present, must be reset to "top-left" */
+	/* The exif orientation tag, if present, must be reset to "top-left",
+	   because the jpeg was saved from a gthumb-generated pixbuf, and
+	   the pixbug image loader always rotates the pixbuf to account for
+	   the orientation tag. This tag change can be performed in memory, 
+	   rather than using the file-based write_orientation_field
+	   function, because edata_src is local to this function, and it
+	   is unref'd below. */
 	set_orientation_in_exif_data (GTH_TRANSFORM_NONE, edata_src);
 
+	/* Update the exif data within the jpeg data, in memory. */
 	jpeg_data_set_exif_data (jdata_dest, edata_src);
 
+	/* Commit the jpeg data in memory to a file. */
 	jpeg_data_save_file (jdata_dest, dest_filename);
 
+	/* Remove the jpeg and exif data in memory. */
 	exif_data_unref (edata_src);
 	jpeg_data_unref (jdata_src);
 	jpeg_data_unref (jdata_dest);
@@ -1827,7 +1836,7 @@ save_thumbnail_cb (gpointer data)
 					      filename,
 					      "jpeg",
 					      NULL, NULL)) {
-				copy_exif_from_orig (idata->src_filename, filename);
+				copy_exif_from_orig_and_reset_orientation (idata->src_filename, filename);
 				ce->album_files = g_list_prepend (ce->album_files, filename);
 			} else
 				g_free (filename);
@@ -2095,7 +2104,7 @@ save_image_preview_cb (gpointer data)
 					      filename,
 					      "jpeg",
 					      NULL, NULL)) {
-				copy_exif_from_orig (idata->src_filename, filename);
+				copy_exif_from_orig_and_reset_orientation (idata->src_filename, filename);
 				ce->album_files = g_list_prepend (ce->album_files, filename);
 			} else
 				g_free (filename);
@@ -2132,7 +2141,7 @@ save_resized_image_cb (gpointer data)
 					      filename,
 					      "jpeg",
 					      NULL, NULL)) {
-				copy_exif_from_orig (idata->src_filename, filename);
+				copy_exif_from_orig_and_reset_orientation (idata->src_filename, filename);
 				ce->album_files = g_list_prepend (ce->album_files, filename);
 				idata->file_size = get_file_size (filename);
 			} else
Index: src/gth-browser.c
===================================================================
RCS file: /cvs/gnome/gthumb/src/gth-browser.c,v
retrieving revision 1.72
diff -u -p -r1.72 gth-browser.c
--- src/gth-browser.c	11 Nov 2006 00:27:18 -0000	1.72
+++ src/gth-browser.c	15 Nov 2006 13:18:51 -0000
@@ -1824,14 +1824,18 @@ save_jpeg_data (GthBrowser *browser,
 	}
 #endif /* HAVE_LIBIPTCDATA */
 
-	if (priv->exif_data != NULL) {
-		/* The exif orientation tag, if present, must be reset to "top-left" */
-		set_orientation_in_exif_data (GTH_TRANSFORM_NONE, priv->exif_data);
+	if (priv->exif_data != NULL) 
 		jpeg_data_set_exif_data (jdata, priv->exif_data);
-	}
 
 	jpeg_data_save_file (jdata, filename);
 	jpeg_data_unref (jdata);
+
+	/* The exif orientation tag, if present, must be reset to "top-left",
+   	   because the jpeg was saved from a gthumb-generated pixbuf, and
+   	   the pixbug image loader always rotates the pixbuf to account for
+   	   the orientation tag. */
+	write_orientation_field (filename, GTH_TRANSFORM_NONE);
+
 }
 
 
Index: src/gth-viewer.c
===================================================================
RCS file: /cvs/gnome/gthumb/src/gth-viewer.c,v
retrieving revision 1.41
diff -u -p -r1.41 gth-viewer.c
--- src/gth-viewer.c	11 Nov 2006 00:27:18 -0000	1.41
+++ src/gth-viewer.c	15 Nov 2006 13:18:51 -0000
@@ -881,14 +881,17 @@ save_jpeg_data (GthViewer  *viewer,
 	}
 #endif /* HAVE_LIBIPTCDATA */
 
-	if (priv->exif_data != NULL) {
-		/* The exif orientation tag, if present, must be reset to "top-left" */
-		set_orientation_in_exif_data (GTH_TRANSFORM_NONE, priv->exif_data);
+	if (priv->exif_data != NULL) 
 		jpeg_data_set_exif_data (jdata, priv->exif_data);
-	}
 
 	jpeg_data_save_file (jdata, filename);
 	jpeg_data_unref (jdata);
+
+	/* The exif orientation tag, if present, must be reset to "top-left",
+   	   because the jpeg was saved from a gthumb-generated pixbuf, and
+   	   the pixbug image loader always rotates the pixbuf to account for
+   	   the orientation tag. */
+	write_orientation_field (filename, GTH_TRANSFORM_NONE);
 }
 
 
