--- gimp-8c2c22ccb4091f77b28b2d5eb8141064a5d55f76/plug-ins/file-jpeg/jpeg.c
+++ gimp-8c2c22ccb4091f77b28b2d5eb8141064a5d55f76-1/plug-ins/file-jpeg/jpeg.c
@@ -446,7 +448,6 @@
               if (orig_quality > jsvals.quality)
                 {
                   jsvals.quality = orig_quality;
-                  jsvals.use_orig_quality = TRUE;
                 }
 
               if (orig_subsmp == JPEG_SUBSAMPLING_1x1_1x1_1x1 ||
@@ -454,6 +455,12 @@
                    jsvals.subsmp == JPEG_SUBSAMPLING_1x1_1x1_1x1))
                 {
                   jsvals.subsmp = orig_subsmp;
+                }
+
+              if (orig_quality == jsvals.quality &&
+                  orig_subsmp == jsvals.subsmp)
+                {
+                  jsvals.use_orig_quality = TRUE;
                 }
             }
           break;
