Commit f77e261c authored by Jehan's avatar Jehan

plug-ins: export with explicit PNG's sRGB chunk when no profile written.

When a profile is set, we should not set the sRGB chunk, because it
would be a contradiction. But when we don't set the profile, then our
code explicitly saves as sRGB. So let's add the sRGB chunk.

Also when we do so, let's also set the relevant gAMA and cHRM chunks
corresponding to sRGB as recommended by the PNG spec:

> An application that writes the sRGB chunk should also write a gAMA
> chunk (and perhaps a cHRM chunk) for compatibility with applications
> that do not use the sRGB chunk. In this situation, only the following
> values may be used: […]

This is why I use png_set_sRGB_gAMA_and_cHRM() and not just
png_set_sRGB().
See also discussions in #5363.
parent 26903fde
Pipeline #247689 passed with stages
in 45 minutes and 43 seconds
......@@ -1714,7 +1714,34 @@ save_image (GFile *file,
g_object_unref (profile);
}
else
#endif
{
/* Be more specific by writing into the file that the image is in
* sRGB color space.
*/
GimpColorConfig *config = gimp_get_color_configuration ();
int srgb_intent;
switch (gimp_color_config_get_display_intent (config))
{
case GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL:
srgb_intent = PNG_sRGB_INTENT_PERCEPTUAL;
break;
case GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC:
srgb_intent = PNG_sRGB_INTENT_RELATIVE;
break;
case GIMP_COLOR_RENDERING_INTENT_SATURATION:
srgb_intent = PNG_sRGB_INTENT_SATURATION;
break;
case GIMP_COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC:
srgb_intent = PNG_sRGB_INTENT_ABSOLUTE;
break;
}
png_set_sRGB_gAMA_and_cHRM (pp, info, srgb_intent);
g_object_unref (config);
}
#ifdef PNG_zTXt_SUPPORTED
/* Small texts are not worth compressing and will be even bigger if compressed.
......
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