[gimp] Bug 492048 - Detect color space in Exif 2.21/DCF 2.0 option files



commit 6bb117286be111a8fe6292b0933d1cb52178ed07
Author: Michael Natterer <mitch gimp org>
Date:   Thu Aug 20 15:05:04 2015 +0200

    Bug 492048 - Detect color space in Exif 2.21/DCF 2.0 option files
    
    Add flag GIMP_METADATA_LOAD_COLORSPACE which defaults to TRUE, and in
    gimp_image_metadata_load_finish(), assign AdobeRGB to the image if
    Exif.Iop.InteroperabilityIndex says "R03". This is most likely very
    incomplete because there are quite some other colorspace tags in
    various parts of the image metadata.

 libgimp/gimpmetadata.c     |   26 ++++++++++++++++++++++++++
 libgimpbase/gimpmetadata.h |    1 +
 2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/libgimp/gimpmetadata.c b/libgimp/gimpmetadata.c
index 2a49cfc..402d83c 100644
--- a/libgimp/gimpmetadata.c
+++ b/libgimp/gimpmetadata.c
@@ -175,6 +175,32 @@ gimp_image_metadata_load_finish (gint32                 image_ID,
                                         metadata, interactive);
     }
 
+  if (flags & GIMP_METADATA_LOAD_COLORSPACE)
+    {
+      gchar *value;
+
+      value = gexiv2_metadata_get_tag_interpreted_string (metadata,
+                                                          "Exif.Iop.InteroperabilityIndex");
+
+      if (! g_strcmp0 (value, "R03"))
+        {
+          GimpColorProfile *profile = gimp_image_get_color_profile (image_ID);
+
+          if (! profile)
+            {
+              /* honor the R03 InteroperabilityIndex only if the
+               * image didn't contain an ICC profile
+               */
+              profile = gimp_color_profile_new_adobe_rgb ();
+              gimp_image_set_color_profile (image_ID, profile);
+            }
+
+          g_object_unref (profile);
+        }
+
+      g_free (value);
+    }
+
   gimp_image_set_metadata (image_ID, metadata);
 }
 
diff --git a/libgimpbase/gimpmetadata.h b/libgimpbase/gimpmetadata.h
index 03bca87..6e6320e 100644
--- a/libgimpbase/gimpmetadata.h
+++ b/libgimpbase/gimpmetadata.h
@@ -29,6 +29,7 @@ typedef enum
   GIMP_METADATA_LOAD_COMMENT     = 1 << 0,
   GIMP_METADATA_LOAD_RESOLUTION  = 1 << 1,
   GIMP_METADATA_LOAD_ORIENTATION = 1 << 2,
+  GIMP_METADATA_LOAD_COLORSPACE  = 1 << 3,
 
   GIMP_METADATA_LOAD_ALL         = 0xffffffff
 } GimpMetadataLoadFlags;


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