[gimp/wip/wormnest/tiff-issue-4176: 97/97] plug-ins: fix #4176 color displayed wrong in multi page tiffs with linear TRC.
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/wormnest/tiff-issue-4176: 97/97] plug-ins: fix #4176 color displayed wrong in multi page tiffs with linear TRC.
- Date: Fri, 20 Nov 2020 19:56:16 +0000 (UTC)
commit 33b6b50f41efa838ab8707abb6ad1c02520be571
Author: Jacob Boerema <jgboerema gmail com>
Date: Fri Nov 20 14:54:30 2020 -0500
plug-ins: fix #4176 color displayed wrong in multi page tiffs with linear TRC.
If we were loading multi page tif images as layers then only the tif pages
that had a color profile attached would get set as linear (and each tiff page
can have a color profile). Since most of the time only the first page has a
color profile this caused us to load linear tiff pages incorrectly.
Also we were overwriting the color profile if there was more than one since
GIMP can only load one per image. Instead of using the last one we see
use the first one and notify if we encounter more than one.
plug-ins/file-tiff/file-tiff-load.c | 36 ++++++++++++++++++++++++++++++++----
1 file changed, 32 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/file-tiff/file-tiff-load.c b/plug-ins/file-tiff/file-tiff-load.c
index 011b551d2b..a8d945b002 100644
--- a/plug-ins/file-tiff/file-tiff-load.c
+++ b/plug-ins/file-tiff/file-tiff-load.c
@@ -161,6 +161,7 @@ load_image (GFile *file,
gint max_row = 0;
gint max_col = 0;
gboolean save_transp_pixels = FALSE;
+ GimpColorProfile *first_profile = NULL;
gint li;
*image = NULL;
@@ -371,12 +372,37 @@ load_image (GFile *file,
TIFFGetFieldDefaulted (tif, TIFFTAG_SAMPLEFORMAT, &sampleformat);
profile = load_profile (tif);
+ if (! profile && first_profile)
+ {
+ profile = first_profile;
+ g_object_ref (profile);
+ }
+
if (profile)
{
+ profile_linear = gimp_color_profile_is_linear (profile);
+
+ if (! first_profile)
+ {
+ first_profile = profile;
+ g_object_ref (first_profile);
+
+ if (profile_linear && li > 0 && pages.target != GIMP_PAGE_SELECTOR_TARGET_IMAGES)
+ g_message (_("This image has a linear color profile but "
+ "it was not set on the first layer. "
+ "The layers below layer # %d will be "
+ "interpreted as non linear."), li+1);
+ }
+ else if (pages.target != GIMP_PAGE_SELECTOR_TARGET_IMAGES && first_profile != profile)
+ {
+ g_message (_("This image has multiple color profiles. "
+ "We will use the first one. If this leads "
+ "to incorrect results you should consider "
+ "loading each layer as a separate image."));
+ }
+
if (! *image)
*profile_loaded = TRUE;
-
- profile_linear = gimp_color_profile_is_linear (profile);
}
if (bps > 8 && bps != 8 && bps != 16 && bps != 32 && bps != 64)
@@ -863,10 +889,11 @@ load_image (GFile *file,
}
/* attach color profile */
-
if (profile)
{
- gimp_image_set_color_profile (*image, profile);
+ if (pages.target == GIMP_PAGE_SELECTOR_TARGET_IMAGES || profile == first_profile)
+ gimp_image_set_color_profile (*image, profile);
+
g_object_unref (profile);
}
@@ -1313,6 +1340,7 @@ load_image (GFile *file,
gimp_progress_update (1.0);
}
+ g_clear_object (&first_profile);
if (pages.target == GIMP_PAGE_SELECTOR_TARGET_IMAGES)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]