Commit 8594275b authored by Jehan's avatar Jehan

Issue #1070: exporting to jpeg from 32-bit float linear image...

... produces jpeg in linear color space.
The problem was that we were anyway always exporting to non-linear while
attaching a linear profile. A first approach would have been to export
in linear instead when the work image is linear, as proposed by mitch in
a first version of the patch. Yet as Elle Stone notes, it is not a great
idea to export 8-bit images as linear.
Instead let's continue to always export as non-linear, as we were
already doing. Yet when we also save a profile, and this one was
originally linear, let's convert it to sRGB TRC before exporting.
parent 6017683c
......@@ -550,14 +550,55 @@ save_image (const gchar *filename,
if (profile)
{
const guint8 *icc_data;
gsize icc_length;
GimpColorProfile *saved_profile;
const guint8 *icc_data;
gsize icc_length;
gboolean linear;
icc_data = gimp_color_profile_get_icc_profile (profile, &icc_length);
switch (gimp_image_get_precision (orig_image_ID))
{
case GIMP_PRECISION_U8_LINEAR:
case GIMP_PRECISION_U16_LINEAR:
case GIMP_PRECISION_U32_LINEAR:
case GIMP_PRECISION_HALF_LINEAR:
case GIMP_PRECISION_FLOAT_LINEAR:
case GIMP_PRECISION_DOUBLE_LINEAR:
linear = TRUE;
break;
case GIMP_PRECISION_U8_NON_LINEAR:
case GIMP_PRECISION_U16_NON_LINEAR:
case GIMP_PRECISION_U32_NON_LINEAR:
case GIMP_PRECISION_HALF_NON_LINEAR:
case GIMP_PRECISION_FLOAT_NON_LINEAR:
case GIMP_PRECISION_DOUBLE_NON_LINEAR:
case GIMP_PRECISION_U8_PERCEPTUAL:
case GIMP_PRECISION_U16_PERCEPTUAL:
case GIMP_PRECISION_U32_PERCEPTUAL:
case GIMP_PRECISION_HALF_PERCEPTUAL:
case GIMP_PRECISION_FLOAT_PERCEPTUAL:
case GIMP_PRECISION_DOUBLE_PERCEPTUAL:
linear = FALSE;
break;
}
/* Though it would be technically possible to export with a
* linear profile, it is not such a great idea to export 8-bit
* formats as linear. This is why our current JPEG exporter
* only exports 8-bit non linear JPEG images.
*/
if (linear)
saved_profile = gimp_color_profile_new_srgb_trc_from_color_profile (profile);
else
saved_profile = profile;
icc_data = gimp_color_profile_get_icc_profile (saved_profile, &icc_length);
jpeg_icc_write_profile (&cinfo, icc_data, icc_length);
g_object_unref (profile);
if (linear)
g_object_unref (saved_profile);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment