[gimp/gimp-2-10] Issue #701 - Add the ability to embed the GIMP built-in sRGB profile...



commit 2f5bbe9416f09140499a68e07e474e05e4a19824
Author: Michael Natterer <mitch gimp org>
Date:   Mon Dec 3 12:55:04 2018 +0100

    Issue #701 - Add the ability to embed the GIMP built-in sRGB profile...
    
    ...upon exporting an image
    
    Add a "Save color profile" toggle to the PNG dialog and always honor it.
    
    (cherry picked from commit 7ed93452e8d2714cda2432fb46878aacfc9d5baa)

 plug-ins/common/file-png.c      | 64 +++++++++++++++++++++++++----------------
 plug-ins/ui/plug-in-file-png.ui | 24 +++++++++++++---
 2 files changed, 59 insertions(+), 29 deletions(-)
---
diff --git a/plug-ins/common/file-png.c b/plug-ins/common/file-png.c
index add85bf30f..05601c3e0f 100644
--- a/plug-ins/common/file-png.c
+++ b/plug-ins/common/file-png.c
@@ -104,28 +104,30 @@ typedef struct
   gboolean  save_xmp;
   gboolean  save_iptc;
   gboolean  save_thumbnail;
+  gboolean  save_profile;
   PngExportFormat export_format;
 }
 PngSaveVals;
 
 typedef struct
 {
-  gboolean   run;
-
-  GtkWidget *interlaced;
-  GtkWidget *bkgd;
-  GtkWidget *gama;
-  GtkWidget *offs;
-  GtkWidget *phys;
-  GtkWidget *time;
-  GtkWidget *comment;
-  GtkWidget *pixelformat;
-  GtkWidget *save_transp_pixels;
+  gboolean       run;
+
+  GtkWidget     *interlaced;
+  GtkWidget     *bkgd;
+  GtkWidget     *gama;
+  GtkWidget     *offs;
+  GtkWidget     *phys;
+  GtkWidget     *time;
+  GtkWidget     *comment;
+  GtkWidget     *pixelformat;
+  GtkWidget     *save_transp_pixels;
   GtkAdjustment *compression_level;
-  GtkWidget *save_exif;
-  GtkWidget *save_xmp;
-  GtkWidget *save_iptc;
-  GtkWidget *save_thumbnail;
+  GtkWidget     *save_exif;
+  GtkWidget     *save_xmp;
+  GtkWidget     *save_iptc;
+  GtkWidget     *save_thumbnail;
+  GtkWidget     *save_profile;
 }
 PngSaveGui;
 
@@ -551,6 +553,7 @@ run (const gchar      *name,
       pngvals.save_xmp       = (metadata_flags & GIMP_METADATA_SAVE_XMP) != 0;
       pngvals.save_iptc      = (metadata_flags & GIMP_METADATA_SAVE_IPTC) != 0;
       pngvals.save_thumbnail = (metadata_flags & GIMP_METADATA_SAVE_THUMBNAIL) != 0;
+      pngvals.save_profile   = gimp_export_color_profile ();
 
       /* Override preferences from PNG export defaults (if saved). */
       load_parasite ();
@@ -1495,7 +1498,8 @@ save_image (const gchar  *filename,
   png_textp         text = NULL;
 
 #if defined(PNG_iCCP_SUPPORTED)
-  profile = gimp_image_get_color_profile (orig_image_ID);
+  if (pngvals.save_profile)
+    profile = gimp_image_get_effective_color_profile (orig_image_ID);
 #endif
 
   switch (gimp_image_get_precision (image_ID))
@@ -2389,18 +2393,25 @@ save_dialog (gint32    image_ID,
   pg.time = toggle_button_init (builder, "save-creation-time",
                                 pngvals.time,
                                 &pngvals.time);
-  pg.save_exif = toggle_button_init (builder, "sv_exif",
+  pg.save_exif = toggle_button_init (builder, "save-exif",
                                      pngvals.save_exif,
                                      &pngvals.save_exif);
-  pg.save_xmp = toggle_button_init (builder, "sv_xmp",
+  pg.save_xmp = toggle_button_init (builder, "save-xmp",
                                     pngvals.save_xmp,
                                     &pngvals.save_xmp);
-  pg.save_iptc = toggle_button_init (builder, "sv_iptc",
+  pg.save_iptc = toggle_button_init (builder, "save-iptc",
                                      pngvals.save_iptc,
                                      &pngvals.save_iptc);
-  pg.save_thumbnail = toggle_button_init (builder, "sv_thumbnail",
+  pg.save_thumbnail = toggle_button_init (builder, "save-thumbnail",
                                           pngvals.save_thumbnail,
                                           &pngvals.save_thumbnail);
+  pg.save_profile = toggle_button_init (builder, "save-color-profile",
+                                        pngvals.save_profile,
+                                        &pngvals.save_profile);
+
+#if !defined(PNG_iCCP_SUPPORTED)
+  gtk_widget_hide (pg.save_profile);
+#endif
 
   /* Comment toggle */
   parasite = gimp_image_get_parasite (image_ID, "gimp-comment");
@@ -2499,7 +2510,7 @@ load_parasite (void)
 
       gimp_parasite_free (parasite);
 
-      num_fields = sscanf (def_str, "%d %d %d %d %d %d %d %d %d %d %d %d %d",
+      num_fields = sscanf (def_str, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d",
                            &tmpvals.interlaced,
                            &tmpvals.bkgd,
                            &tmpvals.gama,
@@ -2512,11 +2523,12 @@ load_parasite (void)
                            &tmpvals.save_exif,
                            &tmpvals.save_xmp,
                            &tmpvals.save_iptc,
-                           &tmpvals.save_thumbnail);
+                           &tmpvals.save_thumbnail,
+                           &tmpvals.save_profile);
 
       g_free (def_str);
 
-      if (num_fields == 9 || num_fields == 13)
+      if (num_fields == 9 || num_fields == 13 || num_fields == 14)
         pngvals = tmpvals;
     }
 }
@@ -2527,7 +2539,7 @@ save_parasite (void)
   GimpParasite *parasite;
   gchar        *def_str;
 
-  def_str = g_strdup_printf ("%d %d %d %d %d %d %d %d %d %d %d %d %d",
+  def_str = g_strdup_printf ("%d %d %d %d %d %d %d %d %d %d %d %d %d %d",
                              pngvals.interlaced,
                              pngvals.bkgd,
                              pngvals.gama,
@@ -2540,7 +2552,8 @@ save_parasite (void)
                              pngvals.save_exif,
                              pngvals.save_xmp,
                              pngvals.save_iptc,
-                             pngvals.save_thumbnail);
+                             pngvals.save_thumbnail,
+                             pngvals.save_profile);
 
   parasite = gimp_parasite_new (PNG_DEFAULTS_PARASITE,
                                 GIMP_PARASITE_PERSISTENT,
@@ -2576,6 +2589,7 @@ load_gui_defaults (PngSaveGui *pg)
   SET_ACTIVE (save_xmp);
   SET_ACTIVE (save_iptc);
   SET_ACTIVE (save_thumbnail);
+  SET_ACTIVE (save_profile);
 
 #undef SET_ACTIVE
 
diff --git a/plug-ins/ui/plug-in-file-png.ui b/plug-ins/ui/plug-in-file-png.ui
index 4995ffe6bb..dc03030eb4 100644
--- a/plug-ins/ui/plug-in-file-png.ui
+++ b/plug-ins/ui/plug-in-file-png.ui
@@ -222,7 +222,7 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <child>
-          <object class="GtkCheckButton" id="sv_exif">
+          <object class="GtkCheckButton" id="save-exif">
             <property name="label" translatable="yes">Save Exif data</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
@@ -238,7 +238,7 @@
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="sv_xmp">
+          <object class="GtkCheckButton" id="save-xmp">
             <property name="label" translatable="yes">Save XMP data</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
@@ -254,7 +254,7 @@
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="sv_iptc">
+          <object class="GtkCheckButton" id="save-iptc">
             <property name="label" translatable="yes">Save IPTC data</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
@@ -270,7 +270,7 @@
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="sv_thumbnail">
+          <object class="GtkCheckButton" id="save-thumbnail">
             <property name="label" translatable="yes">Save thumbnail</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
@@ -285,6 +285,22 @@
             <property name="position">3</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkCheckButton" id="save-color-profile">
+            <property name="label" translatable="yes">Save color profile</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="xalign">0</property>
+            <property name="active">True</property>
+            <property name="draw_indicator">True</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">4</property>
+          </packing>
+        </child>
       </object>
       <packing>
         <property name="right_attach">3</property>


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