[gimp] plug-ins: improve decision on exported data format in Webp.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: improve decision on exported data format in Webp.
- Date: Thu, 6 Jun 2019 13:23:12 +0000 (UTC)
commit 2a1eabc1777c7c25b36b13ae3a48adf8311e6074
Author: Jehan <jehan girinstud io>
Date: Thu Jun 6 14:33:40 2019 +0200
plug-ins: improve decision on exported data format in Webp.
Same as other formats, we make sure that an explicitly set profile TRC
is always followed. When no profile is set, we always export as sRGB
when there is precision downsizing to avoid shadow posterization, since
WebP stores 8-bit max per channel (as far as I know, or at least as far
as we implemented it in our plug-in).
We only take the storage format into account when it is 8-bit linear
with profile export. In such case, we avoid conversion from 8-bit linear
to 8-bit sRGB.
This is different to TIFF export for instance, where we fallback on
following storage format TRC as we are able to export all sort of
precisions, hence with minimum quality loss.
plug-ins/file-webp/file-webp-save.c | 48 ++++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 17 deletions(-)
---
diff --git a/plug-ins/file-webp/file-webp-save.c b/plug-ins/file-webp/file-webp-save.c
index 1adfec3c9b..3d4a087666 100644
--- a/plug-ins/file-webp/file-webp-save.c
+++ b/plug-ins/file-webp/file-webp-save.c
@@ -152,7 +152,7 @@ save_layer (const gchar *filename,
gboolean has_alpha;
const Babl *format;
gint bpp;
- GimpColorProfile *profile;
+ GimpColorProfile *profile = NULL;
GeglBuffer *geglbuffer = NULL;
GeglRectangle extent;
gchar *indata;
@@ -164,26 +164,40 @@ save_layer (const gchar *filename,
int res;
profile = gimp_image_get_color_profile (image_ID);
+
+ /* If a profile is explicitly set, follow its TRC, whatever the
+ * storage format.
+ */
if (profile && gimp_color_profile_is_linear (profile))
+ out_linear = TRUE;
+
+ /* When no profile was explicitly set, since WebP is apparently
+ * 8-bit max, we export it as sRGB to avoid shadow posterization
+ * (we don't care about storage TRC).
+ * We do an exception for 8-bit linear work image to avoid
+ * conversion loss while the precision is the same.
+ */
+ if (! profile)
{
- /* Since WebP is apparently 8-bit max, we export it as sRGB to
- * avoid shadow posterization.
- * We do an exception for 8-bit linear work image, when the
- * profile is also exported.
- */
- if (gimp_image_get_precision (image_ID) != GIMP_PRECISION_U8_LINEAR)
- {
- /* If original data was linear, let's convert the profile. */
- GimpColorProfile *saved_profile;
+ /* There is always an effective profile. */
+ profile = gimp_image_get_effective_color_profile (image_ID);
- saved_profile = gimp_color_profile_new_srgb_trc_from_color_profile (profile);
- g_object_unref (profile);
- profile = saved_profile;
- }
- else
+ if (gimp_color_profile_is_linear (profile))
{
- /* Keep linear profile as-is. */
- out_linear = TRUE;
+ if (gimp_image_get_precision (image_ID) != GIMP_PRECISION_U8_LINEAR)
+ {
+ /* If stored data was linear, let's convert the profile. */
+ GimpColorProfile *saved_profile;
+
+ saved_profile = gimp_color_profile_new_srgb_trc_from_color_profile (profile);
+ g_object_unref (profile);
+ profile = saved_profile;
+ }
+ else
+ {
+ /* Keep linear profile as-is for 8-bit linear image. */
+ out_linear = TRUE;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]