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



commit a865f5e83ebcb517d9b4f93d92ba96462da24863
Author: Michael Natterer <mitch gimp org>
Date:   Mon Dec 3 19:41:56 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 and always honor it.
    
    (partially cherry picked from commit 7f9379cb3281efdcc3823e2c2dd7258a3a986641)

 plug-ins/file-tiff/file-tiff-save.c | 24 ++++++++++++++++++------
 plug-ins/file-tiff/file-tiff-save.h |  1 +
 plug-ins/file-tiff/file-tiff.c      |  4 +++-
 plug-ins/ui/plug-in-file-tiff.ui    | 24 +++++++++++++++++++-----
 4 files changed, 41 insertions(+), 12 deletions(-)
---
diff --git a/plug-ins/file-tiff/file-tiff-save.c b/plug-ins/file-tiff/file-tiff-save.c
index 0764872aae..4c5291cbe8 100644
--- a/plug-ins/file-tiff/file-tiff-save.c
+++ b/plug-ins/file-tiff/file-tiff-save.c
@@ -318,7 +318,8 @@ save_image (GFile        *file,
                              gimp_file_get_utf8_name (file));
 
 #ifdef TIFFTAG_ICCPROFILE
-  profile = gimp_image_get_color_profile (orig_image);
+  if (tsvals->save_profile)
+    profile = gimp_image_get_effective_color_profile (orig_image);
 #endif
 
   drawable_type = gimp_drawable_type (layer);
@@ -1008,7 +1009,7 @@ save_dialog (TiffSaveVals  *tsvals,
   gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
   gtk_widget_show (frame);
 
-  toggle = GTK_WIDGET (gtk_builder_get_object (builder, "sv_alpha"));
+  toggle = GTK_WIDGET (gtk_builder_get_object (builder, "save-alpha"));
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
                                 has_alpha && tsvals->save_transp_pixels);
   gtk_widget_set_sensitive (toggle, has_alpha);
@@ -1023,34 +1024,45 @@ save_dialog (TiffSaveVals  *tsvals,
                     G_CALLBACK (comment_entry_callback),
                     image_comment);
 
-  toggle = GTK_WIDGET (gtk_builder_get_object (builder, "sv_exif"));
+  toggle = GTK_WIDGET (gtk_builder_get_object (builder, "save-exif"));
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
                                 tsvals->save_exif);
   g_signal_connect (toggle, "toggled",
                     G_CALLBACK (gimp_toggle_button_update),
                     &tsvals->save_exif);
 
-  toggle = GTK_WIDGET (gtk_builder_get_object (builder, "sv_xmp"));
+  toggle = GTK_WIDGET (gtk_builder_get_object (builder, "save-xmp"));
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
                                 tsvals->save_xmp);
   g_signal_connect (toggle, "toggled",
                     G_CALLBACK (gimp_toggle_button_update),
                     &tsvals->save_xmp);
 
-  toggle = GTK_WIDGET (gtk_builder_get_object (builder, "sv_iptc"));
+  toggle = GTK_WIDGET (gtk_builder_get_object (builder, "save-iptc"));
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
                                 tsvals->save_iptc);
   g_signal_connect (toggle, "toggled",
                     G_CALLBACK (gimp_toggle_button_update),
                     &tsvals->save_iptc);
 
-  toggle = GTK_WIDGET (gtk_builder_get_object (builder, "sv_thumbnail"));
+  toggle = GTK_WIDGET (gtk_builder_get_object (builder, "save-thumbnail"));
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
                                 tsvals->save_thumbnail);
   g_signal_connect (toggle, "toggled",
                     G_CALLBACK (gimp_toggle_button_update),
                     &tsvals->save_thumbnail);
 
+  toggle = GTK_WIDGET (gtk_builder_get_object (builder, "save-color-profile"));
+#ifdef TIFFTAG_ICCPROFILE
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
+                                tsvals->save_profile);
+  g_signal_connect (toggle, "toggled",
+                    G_CALLBACK (gimp_toggle_button_update),
+                    &tsvals->save_profile);
+#else
+  gtk_widget_hide (toggle);
+#endif
+
   gtk_widget_show (dialog);
 
   run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
diff --git a/plug-ins/file-tiff/file-tiff-save.h b/plug-ins/file-tiff/file-tiff-save.h
index 032b370671..04c6ddc402 100644
--- a/plug-ins/file-tiff/file-tiff-save.h
+++ b/plug-ins/file-tiff/file-tiff-save.h
@@ -32,6 +32,7 @@ typedef struct
   gboolean  save_xmp;
   gboolean  save_iptc;
   gboolean  save_thumbnail;
+  gboolean  save_profile;
 } TiffSaveVals;
 
 
diff --git a/plug-ins/file-tiff/file-tiff.c b/plug-ins/file-tiff/file-tiff.c
index 8a2aa36f0c..11c6873b1e 100644
--- a/plug-ins/file-tiff/file-tiff.c
+++ b/plug-ins/file-tiff/file-tiff.c
@@ -89,7 +89,8 @@ static TiffSaveVals tsvals =
   FALSE,               /*  save exif           */
   FALSE,               /*  save xmp            */
   FALSE,               /*  save iptc           */
-  TRUE                 /*  save thumbnail      */
+  TRUE,                /*  save thumbnail      */
+  TRUE                 /*  save profile        */
 };
 
 static gchar *image_comment = NULL;
@@ -366,6 +367,7 @@ run (const gchar      *name,
       tsvals.save_xmp       = (metadata_flags & GIMP_METADATA_SAVE_XMP) != 0;
       tsvals.save_iptc      = (metadata_flags & GIMP_METADATA_SAVE_IPTC) != 0;
       tsvals.save_thumbnail = (metadata_flags & GIMP_METADATA_SAVE_THUMBNAIL) != 0;
+      tsvals.save_profile   = gimp_export_color_profile ();
 
       parasite = gimp_image_get_parasite (orig_image, "gimp-comment");
       if (parasite)
diff --git a/plug-ins/ui/plug-in-file-tiff.ui b/plug-ins/ui/plug-in-file-tiff.ui
index 52f4e8bf34..49d5852ef4 100644
--- a/plug-ins/ui/plug-in-file-tiff.ui
+++ b/plug-ins/ui/plug-in-file-tiff.ui
@@ -40,7 +40,7 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <child>
-          <object class="GtkCheckButton" id="sv_alpha">
+          <object class="GtkCheckButton" id="save-alpha">
             <property name="label" translatable="yes">Save color values from transparent pixels</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
@@ -123,7 +123,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>
@@ -137,7 +137,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>
@@ -162,7 +162,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <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>
@@ -176,7 +176,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>
@@ -189,6 +189,20 @@
                 <property name="position">1</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="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">True</property>


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