[gimp] plug-ins: run gimp_image_set_color_profile() after image creation.



commit a9ff5e14cef287e672ecb4e0c346d9d70388eed0
Author: Jehan <jehan girinstud io>
Date:   Sat Mar 10 02:00:07 2018 +0100

    plug-ins: run gimp_image_set_color_profile() after image creation.
    
    After moving up the profile extraction, I was running
    gimp_image_set_color_profile() with a non-existing image id, which was
    obviously wrong. Reorder a bit the operations.
    
    Also try to guess the color space from the profile not only with
    OPJ_CLRSPC_UNSPECIFIED but also OPJ_CLRSPC_UNKNOWN images. Indeed I
    encountered a case of .jp2 image with no color space in the header, but
    with an embedded profile. And unlike the .j2c files I encountered
    earlier, the color space was now *_UNKNOWN.
    See https://github.com/uclouvain/openjpeg/issues/1103

 plug-ins/common/file-jp2-load.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/plug-ins/common/file-jp2-load.c b/plug-ins/common/file-jp2-load.c
index 1b41634..778b1ad 100644
--- a/plug-ins/common/file-jp2-load.c
+++ b/plug-ins/common/file-jp2-load.c
@@ -912,7 +912,8 @@ load_image (const gchar       *filename,
           if (! profile)
             goto out;
 
-          if (image->color_space == OPJ_CLRSPC_UNSPECIFIED)
+          if (image->color_space == OPJ_CLRSPC_UNSPECIFIED ||
+              image->color_space == OPJ_CLRSPC_UNKNOWN)
             {
               if (gimp_color_profile_is_rgb (profile))
                 image->color_space = OPJ_CLRSPC_SRGB;
@@ -921,9 +922,6 @@ load_image (const gchar       *filename,
               else if (gimp_color_profile_is_cmyk (profile))
                 image->color_space = OPJ_CLRSPC_CMYK;
             }
-
-          gimp_image_set_color_profile (image_ID, profile);
-          g_object_unref (profile);
         }
       else
         {
@@ -1012,7 +1010,7 @@ load_image (const gchar       *filename,
        * parameter for the API.
        * TODO!
        */
-      base_type  = GIMP_RGB;
+      base_type = GIMP_RGB;
       if (num_components == 3)
         {
           image_type = GIMP_RGB_IMAGE;
@@ -1044,6 +1042,9 @@ load_image (const gchar       *filename,
   image_ID = gimp_image_new (width, height, base_type);
   gimp_image_set_filename (image_ID, filename);
 
+  if (profile)
+    gimp_image_set_color_profile (image_ID, profile);
+
   layer_ID = gimp_layer_new (image_ID,
                              _("Background"),
                              width, height,
@@ -1131,6 +1132,8 @@ load_image (const gchar       *filename,
   gimp_progress_update (1.0);
 
  out:
+  if (profile)
+    g_object_unref (profile);
   if (image)
     opj_image_destroy (image);
   if (codec)


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