[gimp] Bug 769976 - JPEG export ignores quality setting and subsampling fix.



commit 07eb13c73d8b881bf1e173bb40377400ab702b58
Author: Mihail Zenkov <mihail zenkov gmail com>
Date:   Tue Nov 8 15:17:10 2016 +0100

    Bug 769976 - JPEG export ignores quality setting and subsampling fix.
    
    Set use_orig_quality when both the quality and the subsampling are the
    same as in the originally-imported jpeg.
    
    Also improve subsampling initial selection: use the original subsampling
    unless the default one is the best or the original one is the worst.
    The current code was wrong and would often use the default subsampling
    even when worse than the original one.

 plug-ins/file-jpeg/jpeg-save.c |   16 ++++++++++------
 plug-ins/file-jpeg/jpeg.c      |   14 ++++++++++----
 2 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/plug-ins/file-jpeg/jpeg-save.c b/plug-ins/file-jpeg/jpeg-save.c
index 75085e9..c38ff5c 100644
--- a/plug-ins/file-jpeg/jpeg-save.c
+++ b/plug-ins/file-jpeg/jpeg-save.c
@@ -1356,16 +1356,20 @@ load_gui_defaults (JpegSaveGui *pg)
   gtk_adjustment_set_value (restart_markers, jsvals.restart);
   g_signal_handler_unblock (pg->use_restart_markers, pg->handler_id_restart);
 
-
-  gtk_adjustment_set_value (GTK_ADJUSTMENT (pg->quality),
-                            jsvals.quality);
   gtk_adjustment_set_value (GTK_ADJUSTMENT (pg->smoothing),
                             jsvals.smoothing);
 
-  if (gimp_drawable_is_rgb (drawable_ID_global))
+  /* Don't override quality and subsampling setting if we alredy set it from original */
+  if (!jsvals.use_orig_quality)
     {
-      gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (pg->subsmp),
-                                     jsvals.subsmp);
+      gtk_adjustment_set_value (GTK_ADJUSTMENT (pg->quality),
+                                jsvals.quality);
+
+      if (gimp_drawable_is_rgb (drawable_ID_global))
+        {
+          gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (pg->subsmp),
+                                         jsvals.subsmp);
+        }
     }
 
   gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (pg->dct),
diff --git a/plug-ins/file-jpeg/jpeg.c b/plug-ins/file-jpeg/jpeg.c
index 07568fa..5808348 100644
--- a/plug-ins/file-jpeg/jpeg.c
+++ b/plug-ins/file-jpeg/jpeg.c
@@ -446,15 +446,21 @@ run (const gchar      *name,
               if (orig_quality > jsvals.quality)
                 {
                   jsvals.quality = orig_quality;
-                  jsvals.use_orig_quality = TRUE;
                 }
 
-              if (orig_subsmp == JPEG_SUBSAMPLING_1x1_1x1_1x1 ||
-                  ((gint) orig_subsmp > 0 &&
-                   jsvals.subsmp == JPEG_SUBSAMPLING_1x1_1x1_1x1))
+              /* Skip changing subsampling to original if we alredy have best
+               * setting or if original have worst setting */
+              if (!(jsvals.subsmp == JPEG_SUBSAMPLING_1x1_1x1_1x1 ||
+                    orig_subsmp == JPEG_SUBSAMPLING_2x2_1x1_1x1))
                 {
                   jsvals.subsmp = orig_subsmp;
                 }
+
+              if (orig_quality == jsvals.quality &&
+                  orig_subsmp == jsvals.subsmp)
+                {
+                  jsvals.use_orig_quality = TRUE;
+                }
             }
           break;
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]