[gimp] app: do not ask about conversion for an image using a preferred profile.



commit d9b25b8b50262b812b52d1ba00b313aee7ffcd47
Author: Jehan <jehan girinstud io>
Date:   Sun Dec 20 01:13:01 2020 +0100

    app: do not ask about conversion for an image using a preferred profile.
    
    If setting a RGB or Grayscale "preferred" profile, it usually means
    these are profiles we are commonly working with, and it is to be
    expected that images one might load may already have said profile. In
    this case, don't ask what to do with this profile (keep, convert…). The
    graphist kind of already answered this by explicitly listing this
    profile as a "preferred" one.
    
    Note that I also check for the built-in profile equality, though it
    doesn't look like it is useful (gimp_image_get_color_profile() will
    return NULL for an imported image which uses the built-in profile).
    This is mostly to be thorough.

 app/core/gimpimage-color-profile.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimpimage-color-profile.c b/app/core/gimpimage-color-profile.c
index cda2869b19..96eeaf727d 100644
--- a/app/core/gimpimage-color-profile.c
+++ b/app/core/gimpimage-color-profile.c
@@ -570,14 +570,17 @@ gimp_image_import_color_profile (GimpImage    *image,
                                  GimpProgress *progress,
                                  gboolean      interactive)
 {
+  GimpColorProfile *profile = NULL;
+
   g_return_if_fail (GIMP_IS_IMAGE (image));
   g_return_if_fail (GIMP_IS_CONTEXT (context));
   g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
 
-  if (gimp_image_get_color_profile (image))
+  if ((profile = gimp_image_get_color_profile (image)))
     {
       GimpColorProfilePolicy     policy;
       GimpColorProfile          *dest_profile = NULL;
+      GimpColorProfile          *pref_profile = NULL;
       GimpColorRenderingIntent   intent;
       gboolean                   bpc;
 
@@ -585,9 +588,23 @@ gimp_image_import_color_profile (GimpImage    *image,
       intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
       bpc    = TRUE;
 
+      if (gimp_image_get_base_type (image) == GIMP_GRAY)
+        pref_profile = gimp_color_config_get_gray_color_profile (image->gimp->config->color_management, 
NULL);
+      else
+        pref_profile = gimp_color_config_get_rgb_color_profile (image->gimp->config->color_management, NULL);
+
       if (policy == GIMP_COLOR_PROFILE_POLICY_ASK)
         {
-          if (interactive)
+          if (gimp_color_profile_is_equal (profile, gimp_image_get_builtin_color_profile (image)) ||
+              (pref_profile && gimp_color_profile_is_equal (pref_profile, profile)))
+            {
+              /* If already using the default profile or the preferred
+               * profile for the image type, no need to ask. Just keep
+               * the profile.
+               */
+              policy = GIMP_COLOR_PROFILE_POLICY_KEEP;
+            }
+          else if (interactive)
             {
               gboolean dont_ask = FALSE;
 
@@ -636,6 +653,8 @@ gimp_image_import_color_profile (GimpImage    *image,
 
           g_object_unref (dest_profile);
         }
+
+      g_clear_object (&pref_profile);
     }
 }
 


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