Index: src/dlg-jpegtran.c
===================================================================
RCS file: /cvs/gnome/gthumb/src/dlg-jpegtran.c,v
retrieving revision 1.41
diff -u -r1.41 dlg-jpegtran.c
--- src/dlg-jpegtran.c	19 Oct 2006 17:42:29 -0000	1.41
+++ src/dlg-jpegtran.c	30 Oct 2006 22:26:19 -0000
@@ -227,6 +227,32 @@
 }
 
 
+#define GTK_RESPONSE_TRIM 1
+static gint jpeg_mcu_dialog (GtkWindow *parent)
+{
+ 	GtkWidget *d =  _gtk_message_dialog_new (parent,
+		GTK_DIALOG_MODAL,
+		GTK_STOCK_DIALOG_WARNING,
+		_("The lossless JPEG transformation can possibly cause small image distortions along "
+		"one or more edges, because the image dimensions are not multiples of 8.\n\nThe distortion "
+		"is reversible, however. If the resulting image is unacceptable, simply apply the reverse "
+		"transformation to return to the original image.\n\ngThumb can also discard (or trim) any "
+		"untransformable edge pixels. For practical use, this mode gives the best looking results, "
+		"but the transformation is not strictly lossless anymore.\n\nTo avoid this warning in the "
+		"future, disable the \"Apply physical transform\" option in the rotation dialog."),
+		NULL,
+		_("Trim"), GTK_RESPONSE_TRIM,
+		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+		GTK_STOCK_OK, GTK_RESPONSE_OK,
+		NULL);
+	
+	gint result = gtk_dialog_run (GTK_DIALOG (d));
+
+ 	gtk_widget_destroy (d);
+
+ 	return result;
+}
+
 
 static void
 apply_transformation (DialogData *data,
@@ -254,43 +280,33 @@
 
 	gnome_vfs_get_file_info (path, &info, GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS|GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
 
-        if (image_is_jpeg (path)) {
-		int	  width;
-		int	  height;
-		ExifShort orientation;
-			
+	gboolean jpeg = image_is_jpeg (path);
+	ExifShort orientation = get_exif_tag_short(path, EXIF_TAG_ORIENTATION);
+	data->transform = get_next_transformation (orientation, data->transform);
+ 
+	if ((jpeg && orientation) &&
+			!eel_gconf_get_boolean (PREF_ROTATE_RESET_EXIF_ORIENTATION, TRUE)) {
+		// Adjust Exif orientation tag.
+		write_orientation_field (path, data->transform);
+	} else if (jpeg) {
+ 		// Lossless jpeg transform.
+		int width, height;
 		gdk_pixbuf_get_file_info (get_file_path_from_uri (path), &width, &height);
-		
-		orientation = get_exif_tag_short (path, EXIF_TAG_ORIENTATION);
-                if (orientation != 0) {
-			data->transform = get_next_transformation (orientation, data->transform);
-			if (! eel_gconf_get_boolean (PREF_ROTATE_RESET_EXIF_ORIENTATION, TRUE)) {
-				/* Just change the exif orientation tag, and save the file */
-				write_orientation_field (path, data->transform);
-			}
-			else if ((height % 8 == 0) && (width % 8 == 0)) {
-				/* Do a physical transform if requested and if the dimensions are
-				 * multiples of the jpeg mcu (8) */
-				apply_transformation_jpeg (window, path, data->transform);
-			}
-			else {
-				/* Just change the exif orientation tag, and save the file */
-				_gtk_info_dialog_run (window, _("This image can not be physically transformed without image distortion, because its dimensions are not multiples of 8. Instead, gThumb will change the Exif orientation tag to accomplish the rotation without image distortion. To avoid this warning in the future, disable the \"Apply physical transform\" option in the rotation dialog."));
-				write_orientation_field (path, data->transform);
+		if ((height % 8) || (width % 8)) {
+ 			// Image dimensions are not multiples of the jpeg minimal coding unit (mcu).
+ 			// Warn about possible image distortions along one or more edges.
+ 			gint result = jpeg_mcu_dialog (window);
+			if (result != GTK_RESPONSE_CANCEL) {
+				gboolean trim = (result == GTK_RESPONSE_TRIM);
+				apply_transformation_jpeg (window, path, data->transform, trim);
 			}
-                }
-                else {
-                	/* If no exif orientation tag is present, do a physical transform. */
-                	
-			/* Warn about MCU issues, if the image dimensions are not multiples of 8 */
-			if ((height % 8) || (width % 8)) 
-				_gtk_info_dialog_run (window, _("This image will be distorted slightly along one edge, because its dimensions are not multiples of 8 and no Exif orientation tag is present. It is not possible to \"losslessly\" rotate such images. The distortion is reversible, however. If the resulting image is unacceptable, simply apply the reverse transformation to return to the original image."));
-		
-			apply_transformation_jpeg (window, path, data->transform);
+ 		} else {
+			apply_transformation_jpeg (window, path, data->transform, FALSE);
 		}
-        }
-	else 
+	} else {
+		// Generic image transform.
 		apply_transformation_generic (window, path, data->transform);
+	}
 		
 	gnome_vfs_set_file_info (path, &info, GNOME_VFS_SET_FILE_INFO_PERMISSIONS|GNOME_VFS_SET_FILE_INFO_OWNER);
 
Index: src/dlg-photo-importer.c
===================================================================
RCS file: /cvs/gnome/gthumb/src/dlg-photo-importer.c,v
retrieving revision 1.42
diff -u -r1.42 dlg-photo-importer.c
--- src/dlg-photo-importer.c	12 Oct 2006 19:15:12 -0000	1.42
+++ src/dlg-photo-importer.c	30 Oct 2006 22:26:21 -0000
@@ -1373,7 +1373,7 @@
 		FileData     *fd = file_data_new (filepath, &info);
 		GthTransform transform = read_orientation_field (fd->path);
 		if (image_is_jpeg (filepath))
-			apply_transformation_jpeg (window, fd->path, transform);
+			apply_transformation_jpeg (window, fd->path, transform, FALSE);
 		else
 			apply_transformation_generic (window, fd->path, transform);
 
Index: src/rotation-utils.c
===================================================================
RCS file: /cvs/gnome/gthumb/src/rotation-utils.c,v
retrieving revision 1.10
diff -u -r1.10 rotation-utils.c
--- src/rotation-utils.c	19 Oct 2006 17:42:30 -0000	1.10
+++ src/rotation-utils.c	30 Oct 2006 22:26:21 -0000
@@ -98,7 +98,8 @@
 void
 apply_transformation_jpeg (GtkWindow    *win,
 			   const char   *path,
-			   GthTransform transform)
+			   GthTransform transform,
+			   gboolean	    trim)
 {
 	char        *line;
 	char        *tmp;
@@ -146,7 +147,7 @@
 		break;
 	}
 
-	if (jpegtran ((char*)path, tmp, transf, FALSE, &err) != 0) {
+	if (jpegtran ((char*)path, tmp, transf, trim, &err) != 0) {
 		g_free (tmp);
 		if (err != NULL) 
 			_gtk_error_dialog_from_gerror_run (win, &err);
Index: src/rotation-utils.h
===================================================================
RCS file: /cvs/gnome/gthumb/src/rotation-utils.h,v
retrieving revision 1.6
diff -u -r1.6 rotation-utils.h
--- src/rotation-utils.h	19 Oct 2006 17:42:30 -0000	1.6
+++ src/rotation-utils.h	30 Oct 2006 22:26:21 -0000
@@ -31,7 +31,8 @@
 
 void		apply_transformation_jpeg      (GtkWindow    *win,
 						const char   *filename,
-						GthTransform  transform);
+						GthTransform  transform,
+						gboolean	     trim);
 void		apply_transformation_generic   (GtkWindow    *win,
 						const char   *filename,
 						GthTransform  transform);
