[gimp/blend-tool-fun: 102/163] Bug 492048 - Detect color space in Exif 2.21/DCF 2.0 option files



commit 04eced1ea460844867833d092b72b7f698b615fe
Author: Michael Natterer <mitch gimp org>
Date:   Tue Oct 6 21:32:12 2015 +0200

    Bug 492048 - Detect color space in Exif 2.21/DCF 2.0 option files
    
    Change the logic in gimp_metadata_get_colorspace() to be like in the
    respective KExiv2 function, which looks pretty well done. No guarantee
    of correctness, this just looks more logical than before :)

 libgimpbase/gimpmetadata.c |  100 ++++++++++++++++++++++++--------------------
 1 files changed, 55 insertions(+), 45 deletions(-)
---
diff --git a/libgimpbase/gimpmetadata.c b/libgimpbase/gimpmetadata.c
index 0495699..39d2d97 100644
--- a/libgimpbase/gimpmetadata.c
+++ b/libgimpbase/gimpmetadata.c
@@ -918,7 +918,7 @@ gimp_metadata_set_resolution (GimpMetadata *metadata,
 GimpMetadataColorspace
 gimp_metadata_get_colorspace (GimpMetadata *metadata)
 {
-  glong colorspace = -1;
+  glong exif_cs = -1;
 
   g_return_val_if_fail (GEXIV2_IS_METADATA (metadata),
                         GIMP_METADATA_COLORSPACE_UNSPECIFIED);
@@ -927,74 +927,84 @@ gimp_metadata_get_colorspace (GimpMetadata *metadata)
 
   if (gexiv2_metadata_has_tag (metadata, "Exif.Photo.ColorSpace"))
     {
-      colorspace = gexiv2_metadata_get_tag_long (metadata,
-                                                 "Exif.Photo.ColorSpace");
+      exif_cs = gexiv2_metadata_get_tag_long (metadata,
+                                              "Exif.Photo.ColorSpace");
     }
   else if (gexiv2_metadata_has_tag (metadata, "Xmp.exif.ColorSpace"))
     {
-      colorspace = gexiv2_metadata_get_tag_long (metadata,
-                                                 "Xmp.exif.ColorSpace");
+      exif_cs = gexiv2_metadata_get_tag_long (metadata,
+                                              "Xmp.exif.ColorSpace");
     }
 
-  if (colorspace == 0x01)
+  if (exif_cs == 0x01)
     {
       return GIMP_METADATA_COLORSPACE_SRGB;
     }
-  else if (colorspace == 0x02)
+  else if (exif_cs == 0x02)
     {
       return GIMP_METADATA_COLORSPACE_ADOBERGB;
     }
-  else if (colorspace == 0xffff)
+  else
     {
-      gchar *iop_index;
-
-      iop_index = gexiv2_metadata_get_tag_string (metadata,
-                                                  "Exif.Iop.InteroperabilityIndex");
-
-      if (! g_strcmp0 (iop_index, "R03"))
+      if (exif_cs == 0xffff)
         {
-          g_free (iop_index);
+          gchar *iop_index;
 
-          return GIMP_METADATA_COLORSPACE_ADOBERGB;
-        }
-      else if (! g_strcmp0 (iop_index, "R98"))
-        {
-          g_free (iop_index);
+          iop_index = gexiv2_metadata_get_tag_string (metadata,
+                                                      "Exif.Iop.InteroperabilityIndex");
 
-          return GIMP_METADATA_COLORSPACE_SRGB;
-        }
+          if (! g_strcmp0 (iop_index, "R03"))
+            {
+              g_free (iop_index);
 
-      g_free (iop_index);
+              return GIMP_METADATA_COLORSPACE_ADOBERGB;
+            }
+          else if (! g_strcmp0 (iop_index, "R98"))
+            {
+              g_free (iop_index);
 
-      return GIMP_METADATA_COLORSPACE_UNCALIBRATED;
-    }
-  else if (gexiv2_metadata_has_tag (metadata, "Exif.Nikon3.ColorSpace"))
-    {
-      colorspace = gexiv2_metadata_get_tag_long (metadata,
-                                                 "Exif.Nikon3.ColorSpace");
+              return GIMP_METADATA_COLORSPACE_SRGB;
+            }
 
-      if (colorspace == 0x01)
-        {
-          return GIMP_METADATA_COLORSPACE_SRGB;
-        }
-      else if (colorspace == 0x02)
-        {
-          return GIMP_METADATA_COLORSPACE_ADOBERGB;
+          g_free (iop_index);
         }
-    }
-  else if (gexiv2_metadata_has_tag (metadata, "Exif.Canon.ColorSpace"))
-    {
-      colorspace = gexiv2_metadata_get_tag_long (metadata,
-                                                 "Exif.Canon.ColorSpace");
 
-      if (colorspace == 0x01)
+      if (gexiv2_metadata_has_tag (metadata, "Exif.Nikon3.ColorSpace"))
         {
-          return GIMP_METADATA_COLORSPACE_SRGB;
+          glong nikon_cs;
+
+          nikon_cs = gexiv2_metadata_get_tag_long (metadata,
+                                                   "Exif.Nikon3.ColorSpace");
+
+          if (nikon_cs == 0x01)
+            {
+              return GIMP_METADATA_COLORSPACE_SRGB;
+            }
+          else if (nikon_cs == 0x02)
+            {
+              return GIMP_METADATA_COLORSPACE_ADOBERGB;
+            }
         }
-      else if (colorspace == 0x02)
+
+      if (gexiv2_metadata_has_tag (metadata, "Exif.Canon.ColorSpace"))
         {
-          return GIMP_METADATA_COLORSPACE_ADOBERGB;
+          glong canon_cs;
+
+          canon_cs = gexiv2_metadata_get_tag_long (metadata,
+                                                   "Exif.Canon.ColorSpace");
+
+          if (canon_cs == 0x01)
+            {
+              return GIMP_METADATA_COLORSPACE_SRGB;
+            }
+          else if (canon_cs == 0x02)
+            {
+              return GIMP_METADATA_COLORSPACE_ADOBERGB;
+            }
         }
+
+      if (exif_cs == 0xffff)
+        return GIMP_METADATA_COLORSPACE_UNCALIBRATED;
     }
 
   return GIMP_METADATA_COLORSPACE_UNSPECIFIED;


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