[gimp] plug-ins: add a "Save color profile" checkbox in WebP export.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: add a "Save color profile" checkbox in WebP export.
- Date: Thu, 6 Jun 2019 13:30:22 +0000 (UTC)
commit 96e37dfdaf796fc804bf12e4eab1e32ed27f6ca9
Author: Jehan <jehan girinstud io>
Date: Thu Jun 6 15:29:07 2019 +0200
plug-ins: add a "Save color profile" checkbox in WebP export.
Unlike most other formats, it didn't have one yet!
plug-ins/file-webp/file-webp-dialog.c | 9 +++++
plug-ins/file-webp/file-webp-save.c | 66 ++++++++++++++++++++---------------
plug-ins/file-webp/file-webp-save.h | 1 +
plug-ins/file-webp/file-webp.c | 7 ++--
4 files changed, 51 insertions(+), 32 deletions(-)
---
diff --git a/plug-ins/file-webp/file-webp-dialog.c b/plug-ins/file-webp/file-webp-dialog.c
index c98472555f..e6ecd7f488 100644
--- a/plug-ins/file-webp/file-webp-dialog.c
+++ b/plug-ins/file-webp/file-webp-dialog.c
@@ -396,6 +396,15 @@ save_dialog (WebPSaveParams *params,
G_CALLBACK (gimp_toggle_button_update),
¶ms->xmp);
+ /* Color profile */
+ toggle = gtk_check_button_new_with_mnemonic (_("Save color _profile"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), params->profile);
+ gtk_box_pack_start (GTK_BOX (vbox2), toggle, FALSE, FALSE, 0);
+ gtk_widget_show (toggle);
+
+ g_signal_connect (toggle, "toggled",
+ G_CALLBACK (gimp_toggle_button_update),
+ ¶ms->profile);
gtk_widget_show (dialog);
diff --git a/plug-ins/file-webp/file-webp-save.c b/plug-ins/file-webp/file-webp-save.c
index 3d4a087666..009914ad7d 100644
--- a/plug-ins/file-webp/file-webp-save.c
+++ b/plug-ins/file-webp/file-webp-save.c
@@ -163,40 +163,43 @@ save_layer (const gchar *filename,
gboolean out_linear = FALSE;
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)
+ if (params->profile)
{
- /* There is always an effective profile. */
- profile = gimp_image_get_effective_color_profile (image_ID);
+ profile = gimp_image_get_color_profile (image_ID);
- if (gimp_color_profile_is_linear (profile))
+ /* 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)
{
- if (gimp_image_get_precision (image_ID) != GIMP_PRECISION_U8_LINEAR)
- {
- /* If stored 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 for 8-bit linear image. */
- 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;
+ }
}
}
}
@@ -862,6 +865,11 @@ save_image (const gchar *filename,
metadata_flags &= ~GIMP_METADATA_SAVE_IPTC;
}
+ if (params->profile)
+ metadata_flags |= GIMP_METADATA_SAVE_COLOR_PROFILE;
+ else
+ metadata_flags &= ~GIMP_METADATA_SAVE_COLOR_PROFILE;
+
file = g_file_new_for_path (filename);
gimp_image_metadata_save_finish (image_ID,
"image/webp",
diff --git a/plug-ins/file-webp/file-webp-save.h b/plug-ins/file-webp/file-webp-save.h
index afd70a9749..b0b5a552be 100644
--- a/plug-ins/file-webp/file-webp-save.h
+++ b/plug-ins/file-webp/file-webp-save.h
@@ -36,6 +36,7 @@ typedef struct
gboolean exif;
gboolean iptc;
gboolean xmp;
+ gboolean profile;
gint delay;
gboolean force_delay;
} WebPSaveParams;
diff --git a/plug-ins/file-webp/file-webp.c b/plug-ins/file-webp/file-webp.c
index 2628beb9d6..7c9d627731 100644
--- a/plug-ins/file-webp/file-webp.c
+++ b/plug-ins/file-webp/file-webp.c
@@ -211,9 +211,10 @@ run (const gchar *name,
metadata = gimp_image_metadata_save_prepare (image_ID,
"image/webp",
&metadata_flags);
- params.exif = (metadata_flags & GIMP_METADATA_SAVE_EXIF) != 0;
- params.xmp = (metadata_flags & GIMP_METADATA_SAVE_XMP) != 0;
- params.iptc = (metadata_flags & GIMP_METADATA_SAVE_IPTC) != 0;
+ params.exif = (metadata_flags & GIMP_METADATA_SAVE_EXIF) != 0;
+ params.xmp = (metadata_flags & GIMP_METADATA_SAVE_XMP) != 0;
+ params.iptc = (metadata_flags & GIMP_METADATA_SAVE_IPTC) != 0;
+ params.profile = (metadata_flags & GIMP_METADATA_SAVE_COLOR_PROFILE) != 0;
/* Possibly override with session data */
gimp_get_data (SAVE_PROC, ¶ms);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]