Issue #3532 - Wrong color profile on nikon taken photos, it's...
...always AdobeRGB!
Change all file plug-ins to never call gimp_image_metadata_load_finish()
with the GIMP_METADATA_LOAD_COLORSPACE when they loaded a color profile.
This keeps gimp_image_metadata_load_finish() from assigning a profile
from DCT even if the loaded profile was GIMP's built-in sRGB.
(cherry picked from commit a08293dc74)
This commit is contained in:
@ -528,10 +528,7 @@ load_image (GFile *file,
|
||||
gimp_image_set_filename (image_ID, g_file_get_uri (file));
|
||||
|
||||
if (profile)
|
||||
{
|
||||
gimp_image_set_color_profile (image_ID, profile);
|
||||
g_object_unref (profile);
|
||||
}
|
||||
gimp_image_set_color_profile (image_ID, profile);
|
||||
|
||||
layer_ID = gimp_layer_new (image_ID,
|
||||
_("image content"),
|
||||
@ -604,7 +601,8 @@ load_image (GFile *file,
|
||||
|
||||
if (exif_data || xmp_data)
|
||||
{
|
||||
GimpMetadata *metadata = gimp_metadata_new ();
|
||||
GimpMetadata *metadata = gimp_metadata_new ();
|
||||
GimpMetadataLoadFlags flags = GIMP_METADATA_LOAD_ALL;
|
||||
|
||||
if (exif_data)
|
||||
gimp_metadata_set_from_exif (metadata,
|
||||
@ -614,12 +612,18 @@ load_image (GFile *file,
|
||||
gimp_metadata_set_from_xmp (metadata,
|
||||
xmp_data, xmp_data_size, NULL);
|
||||
|
||||
if (profile)
|
||||
flags &= ~GIMP_METADATA_LOAD_COLORSPACE;
|
||||
|
||||
gimp_image_metadata_load_finish (image_ID, "image/heif",
|
||||
metadata, GIMP_METADATA_LOAD_ALL,
|
||||
metadata, flags,
|
||||
interactive);
|
||||
}
|
||||
}
|
||||
|
||||
if (profile)
|
||||
g_object_unref (profile);
|
||||
|
||||
heif_image_handle_release (handle);
|
||||
heif_context_free (ctx);
|
||||
heif_image_release (img);
|
||||
|
||||
@ -104,6 +104,7 @@ static gint32 load_image (const gchar *filename,
|
||||
OPJ_CODEC_FORMAT format,
|
||||
OPJ_COLOR_SPACE color_space,
|
||||
gboolean interactive,
|
||||
gboolean *profile_loaded,
|
||||
GError **error);
|
||||
|
||||
static OPJ_COLOR_SPACE open_dialog (const gchar *filename,
|
||||
@ -206,6 +207,7 @@ run (const gchar *name,
|
||||
GimpRunMode run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint image_ID;
|
||||
gboolean profile_loaded = FALSE;
|
||||
GError *error = NULL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
@ -232,6 +234,7 @@ run (const gchar *name,
|
||||
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
||||
interactive = TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (strcmp (name, LOAD_J2K_PROC) == 0)
|
||||
{
|
||||
@ -266,11 +269,17 @@ run (const gchar *name,
|
||||
}
|
||||
|
||||
if (strcmp (name, LOAD_JP2_PROC) == 0)
|
||||
image_ID = load_image (param[1].data.d_string, OPJ_CODEC_JP2,
|
||||
color_space, interactive, &error);
|
||||
{
|
||||
image_ID = load_image (param[1].data.d_string, OPJ_CODEC_JP2,
|
||||
color_space, interactive, &profile_loaded,
|
||||
&error);
|
||||
}
|
||||
else /* strcmp (name, LOAD_J2K_PROC) == 0 */
|
||||
image_ID = load_image (param[1].data.d_string, OPJ_CODEC_J2K,
|
||||
color_space, interactive, &error);
|
||||
{
|
||||
image_ID = load_image (param[1].data.d_string, OPJ_CODEC_J2K,
|
||||
color_space, interactive, &profile_loaded,
|
||||
&error);
|
||||
}
|
||||
|
||||
if (image_ID != -1)
|
||||
{
|
||||
@ -284,6 +293,9 @@ run (const gchar *name,
|
||||
{
|
||||
GimpMetadataLoadFlags flags = GIMP_METADATA_LOAD_ALL;
|
||||
|
||||
if (profile_loaded)
|
||||
flags &= ~GIMP_METADATA_LOAD_COLORSPACE;
|
||||
|
||||
gimp_image_metadata_load_finish (image_ID, "image/jp2",
|
||||
metadata, flags,
|
||||
interactive);
|
||||
@ -1028,6 +1040,7 @@ load_image (const gchar *filename,
|
||||
OPJ_CODEC_FORMAT format,
|
||||
OPJ_COLOR_SPACE color_space,
|
||||
gboolean interactive,
|
||||
gboolean *profile_loaded,
|
||||
GError **error)
|
||||
{
|
||||
opj_stream_t *stream;
|
||||
@ -1118,6 +1131,8 @@ load_image (const gchar *filename,
|
||||
if (! profile)
|
||||
goto out;
|
||||
|
||||
*profile_loaded = TRUE;
|
||||
|
||||
if (image->color_space == OPJ_CLRSPC_UNSPECIFIED ||
|
||||
image->color_space == OPJ_CLRSPC_UNKNOWN)
|
||||
{
|
||||
|
||||
@ -158,6 +158,7 @@ static void run (const gchar *name,
|
||||
static gint32 load_image (const gchar *filename,
|
||||
gboolean interactive,
|
||||
gboolean *resolution_loaded,
|
||||
gboolean *profile_loaded,
|
||||
GError **error);
|
||||
static gboolean save_image (const gchar *filename,
|
||||
gint32 image_ID,
|
||||
@ -452,6 +453,7 @@ run (const gchar *name,
|
||||
{
|
||||
gboolean interactive;
|
||||
gboolean resolution_loaded = FALSE;
|
||||
gboolean profile_loaded = FALSE;
|
||||
|
||||
switch (run_mode)
|
||||
{
|
||||
@ -468,6 +470,7 @@ run (const gchar *name,
|
||||
image_ID = load_image (param[1].data.d_string,
|
||||
interactive,
|
||||
&resolution_loaded,
|
||||
&profile_loaded,
|
||||
&error);
|
||||
|
||||
if (image_ID != -1)
|
||||
@ -485,6 +488,9 @@ run (const gchar *name,
|
||||
if (resolution_loaded)
|
||||
flags &= ~GIMP_METADATA_LOAD_RESOLUTION;
|
||||
|
||||
if (profile_loaded)
|
||||
flags &= ~GIMP_METADATA_LOAD_COLORSPACE;
|
||||
|
||||
gimp_image_metadata_load_finish (image_ID, "image/png",
|
||||
metadata, flags,
|
||||
interactive);
|
||||
@ -849,6 +855,7 @@ static gint32
|
||||
load_image (const gchar *filename,
|
||||
gboolean interactive,
|
||||
gboolean *resolution_loaded,
|
||||
gboolean *profile_loaded,
|
||||
GError **error)
|
||||
{
|
||||
gint i; /* Looping var */
|
||||
@ -955,7 +962,11 @@ load_image (const gchar *filename,
|
||||
profile = load_color_profile (pp, info, &profile_name);
|
||||
|
||||
if (profile)
|
||||
linear = gimp_color_profile_is_linear (profile);
|
||||
{
|
||||
*profile_loaded = TRUE;
|
||||
|
||||
linear = gimp_color_profile_is_linear (profile);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get image precision and color model
|
||||
|
||||
@ -278,6 +278,7 @@ load_image_resource (PSDimageres *res_a,
|
||||
PSDimage *img_a,
|
||||
FILE *f,
|
||||
gboolean *resolution_loaded,
|
||||
gboolean *profile_loaded,
|
||||
GError **error)
|
||||
{
|
||||
gint pad;
|
||||
@ -367,7 +368,8 @@ load_image_resource (PSDimageres *res_a,
|
||||
break;
|
||||
|
||||
case PSD_ICC_PROFILE:
|
||||
load_resource_1039 (res_a, image_id, f, error);
|
||||
if (! load_resource_1039 (res_a, image_id, f, error))
|
||||
*profile_loaded = TRUE;
|
||||
break;
|
||||
|
||||
case PSD_ALPHA_NAMES_UNI:
|
||||
|
||||
@ -31,6 +31,7 @@ gint load_image_resource (PSDimageres *res_a,
|
||||
PSDimage *img_a,
|
||||
FILE *f,
|
||||
gboolean *resolution_loaded,
|
||||
gboolean *profile_loaded,
|
||||
GError **error);
|
||||
|
||||
gint load_thumbnail_resource (PSDimageres *res_a,
|
||||
|
||||
@ -70,6 +70,7 @@ static gint add_image_resources (gint32 image_id,
|
||||
PSDimage *img_a,
|
||||
FILE *f,
|
||||
gboolean *resolution_loaded,
|
||||
gboolean *profile_loaded,
|
||||
GError **error);
|
||||
|
||||
static gint add_layers (gint32 image_id,
|
||||
@ -115,6 +116,7 @@ gint32
|
||||
load_image (const gchar *filename,
|
||||
gboolean merged_image_only,
|
||||
gboolean *resolution_loaded,
|
||||
gboolean *profile_loaded,
|
||||
GError **load_error)
|
||||
{
|
||||
FILE *f;
|
||||
@ -189,7 +191,9 @@ load_image (const gchar *filename,
|
||||
|
||||
/* ----- Add image resources ----- */
|
||||
IFDBG(2) g_debug ("Add image resources");
|
||||
if (add_image_resources (image_id, &img_a, f, resolution_loaded, &error) < 0)
|
||||
if (add_image_resources (image_id, &img_a, f,
|
||||
resolution_loaded, profile_loaded,
|
||||
&error) < 0)
|
||||
goto load_error;
|
||||
gimp_progress_update (0.8);
|
||||
|
||||
@ -1064,6 +1068,7 @@ add_image_resources (gint32 image_id,
|
||||
PSDimage *img_a,
|
||||
FILE *f,
|
||||
gboolean *resolution_loaded,
|
||||
gboolean *profile_loaded,
|
||||
GError **error)
|
||||
{
|
||||
PSDimageres res_a;
|
||||
@ -1097,7 +1102,8 @@ add_image_resources (gint32 image_id,
|
||||
}
|
||||
|
||||
if (load_image_resource (&res_a, image_id, img_a, f,
|
||||
resolution_loaded, error) < 0)
|
||||
resolution_loaded, profile_loaded,
|
||||
error) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
gint32 load_image (const gchar *filename,
|
||||
gboolean merged_image_only,
|
||||
gboolean *resolution_loaded,
|
||||
gboolean *profile_loaded,
|
||||
GError **error);
|
||||
|
||||
|
||||
|
||||
@ -202,6 +202,7 @@ run (const gchar *name,
|
||||
strcmp (name, LOAD_MERGED_PROC) == 0)
|
||||
{
|
||||
gboolean resolution_loaded = FALSE;
|
||||
gboolean profile_loaded = FALSE;
|
||||
gboolean interactive;
|
||||
|
||||
switch (run_mode)
|
||||
@ -218,7 +219,9 @@ run (const gchar *name,
|
||||
|
||||
image_ID = load_image (param[1].data.d_string,
|
||||
strcmp (name, LOAD_MERGED_PROC) == 0,
|
||||
&resolution_loaded, &error);
|
||||
&resolution_loaded,
|
||||
&profile_loaded,
|
||||
&error);
|
||||
|
||||
if (image_ID != -1)
|
||||
{
|
||||
@ -235,6 +238,9 @@ run (const gchar *name,
|
||||
if (resolution_loaded)
|
||||
flags &= ~GIMP_METADATA_LOAD_RESOLUTION;
|
||||
|
||||
if (profile_loaded)
|
||||
flags &= ~GIMP_METADATA_LOAD_COLORSPACE;
|
||||
|
||||
gimp_image_metadata_load_finish (image_ID, "image/x-psd",
|
||||
metadata, flags,
|
||||
interactive);
|
||||
|
||||
@ -151,6 +151,7 @@ load_image (GFile *file,
|
||||
GimpRunMode run_mode,
|
||||
gint32 *image,
|
||||
gboolean *resolution_loaded,
|
||||
gboolean *profile_loaded,
|
||||
GError **error)
|
||||
{
|
||||
TIFF *tif;
|
||||
@ -341,7 +342,12 @@ load_image (GFile *file,
|
||||
|
||||
profile = load_profile (tif);
|
||||
if (profile)
|
||||
profile_linear = gimp_color_profile_is_linear (profile);
|
||||
{
|
||||
if (! *image)
|
||||
*profile_loaded = TRUE;
|
||||
|
||||
profile_linear = gimp_color_profile_is_linear (profile);
|
||||
}
|
||||
|
||||
if (bps > 8 && bps != 8 && bps != 16 && bps != 32 && bps != 64)
|
||||
worst_case = TRUE; /* Wrong sample width => RGBA */
|
||||
@ -1195,6 +1201,7 @@ load_image (GFile *file,
|
||||
min_col = 0;
|
||||
min_row = 0;
|
||||
}
|
||||
|
||||
/* resize image to bounding box of all layers */
|
||||
gimp_image_resize (*image,
|
||||
max_col - min_col, max_row - min_row,
|
||||
|
||||
@ -34,11 +34,12 @@ typedef struct
|
||||
} TiffSelectedPages;
|
||||
|
||||
|
||||
GimpPDBStatusType load_image (GFile *file,
|
||||
GimpRunMode run_mode,
|
||||
gint32 *image,
|
||||
gboolean *resolution_loaded,
|
||||
GError **error);
|
||||
GimpPDBStatusType load_image (GFile *file,
|
||||
GimpRunMode run_mode,
|
||||
gint32 *image,
|
||||
gboolean *resolution_loaded,
|
||||
gboolean *profile_loaded,
|
||||
GError **error);
|
||||
|
||||
|
||||
#endif /* __FILE_TIFF_LOAD_H__ */
|
||||
|
||||
@ -211,12 +211,14 @@ run (const gchar *name,
|
||||
GFile *file = g_file_new_for_uri (param[1].data.d_string);
|
||||
gint32 image = 0;
|
||||
gboolean resolution_loaded = FALSE;
|
||||
gboolean profile_loaded = FALSE;
|
||||
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
||||
|
||||
status = load_image (file, run_mode, &image,
|
||||
&resolution_loaded,
|
||||
&profile_loaded,
|
||||
&error);
|
||||
|
||||
if (image > 0)
|
||||
@ -234,6 +236,9 @@ run (const gchar *name,
|
||||
if (resolution_loaded)
|
||||
flags &= ~GIMP_METADATA_LOAD_RESOLUTION;
|
||||
|
||||
if (profile_loaded)
|
||||
flags &= ~GIMP_METADATA_LOAD_COLORSPACE;
|
||||
|
||||
gimp_image_metadata_load_finish (image, "image/tiff",
|
||||
metadata, flags,
|
||||
run_mode == GIMP_RUN_INTERACTIVE);
|
||||
|
||||
@ -77,18 +77,19 @@ load_image (const gchar *filename,
|
||||
gboolean interactive,
|
||||
GError **error)
|
||||
{
|
||||
uint8_t *indata = NULL;
|
||||
gsize indatalen;
|
||||
gint width;
|
||||
gint height;
|
||||
gint32 image_ID;
|
||||
WebPMux *mux;
|
||||
WebPData wp_data;
|
||||
uint32_t flags;
|
||||
gboolean animation = FALSE;
|
||||
gboolean icc = FALSE;
|
||||
gboolean exif = FALSE;
|
||||
gboolean xmp = FALSE;
|
||||
uint8_t *indata = NULL;
|
||||
gsize indatalen;
|
||||
gint width;
|
||||
gint height;
|
||||
gint32 image_ID;
|
||||
WebPMux *mux;
|
||||
WebPData wp_data;
|
||||
GimpColorProfile *profile = NULL;
|
||||
uint32_t flags;
|
||||
gboolean animation = FALSE;
|
||||
gboolean icc = FALSE;
|
||||
gboolean exif = FALSE;
|
||||
gboolean xmp = FALSE;
|
||||
|
||||
/* Attempt to read the file contents from disk */
|
||||
if (! g_file_get_contents (filename,
|
||||
@ -135,6 +136,17 @@ load_image (const gchar *filename,
|
||||
/* Create the new image and associated layer */
|
||||
image_ID = gimp_image_new (width, height, GIMP_RGB);
|
||||
|
||||
if (icc)
|
||||
{
|
||||
WebPData icc_profile;
|
||||
|
||||
WebPMuxGetChunk (mux, "ICCP", &icc_profile);
|
||||
profile = gimp_color_profile_new_from_icc_profile (icc_profile.bytes,
|
||||
icc_profile.size, NULL);
|
||||
if (profile)
|
||||
gimp_image_set_color_profile (image_ID, profile);
|
||||
}
|
||||
|
||||
if (! animation)
|
||||
{
|
||||
uint8_t *outdata;
|
||||
@ -233,21 +245,6 @@ load_image (const gchar *filename,
|
||||
/* Free the original compressed data */
|
||||
g_free (indata);
|
||||
|
||||
if (icc)
|
||||
{
|
||||
WebPData icc_profile;
|
||||
GimpColorProfile *profile;
|
||||
|
||||
WebPMuxGetChunk (mux, "ICCP", &icc_profile);
|
||||
profile = gimp_color_profile_new_from_icc_profile (icc_profile.bytes,
|
||||
icc_profile.size, NULL);
|
||||
if (profile)
|
||||
{
|
||||
gimp_image_set_color_profile (image_ID, profile);
|
||||
g_object_unref (profile);
|
||||
}
|
||||
}
|
||||
|
||||
if (exif || xmp)
|
||||
{
|
||||
GimpMetadata *metadata;
|
||||
@ -272,8 +269,13 @@ load_image (const gchar *filename,
|
||||
file, NULL);
|
||||
if (metadata)
|
||||
{
|
||||
GimpMetadataLoadFlags flags = GIMP_METADATA_LOAD_ALL;
|
||||
|
||||
if (profile)
|
||||
flags &= ~GIMP_METADATA_LOAD_COLORSPACE;
|
||||
|
||||
gimp_image_metadata_load_finish (image_ID, "image/webp",
|
||||
metadata, GIMP_METADATA_LOAD_ALL,
|
||||
metadata, flags,
|
||||
interactive);
|
||||
g_object_unref (metadata);
|
||||
}
|
||||
@ -285,5 +287,8 @@ load_image (const gchar *filename,
|
||||
|
||||
gimp_image_set_filename (image_ID, filename);
|
||||
|
||||
if (profile)
|
||||
g_object_unref (profile);
|
||||
|
||||
return image_ID;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user