[gimp] plug-ins: fix #7613 overwrite export creates thumbnail when it shouldn't
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: fix #7613 overwrite export creates thumbnail when it shouldn't
- Date: Sun, 22 May 2022 18:01:16 +0000 (UTC)
commit a96dc81ee5452385a3a1d42f86799d015ad75f88
Author: Jacob Boerema <jgboerema gmail com>
Date: Sun May 22 14:00:36 2022 -0400
plug-ins: fix #7613 overwrite export creates thumbnail when it shouldn't
When overwriting the same file when exporting, we didn't check if the
image previously had a thumbnail. If the default setting in Preferences
is to add a thumbnail, then it would add one where it shouldn't.
Since thumbnails get saves as part of the EXIF metadata, we need to check
that to see if there was a thumbnail in the original image.
However, we were always removing the thumbnail from the metadata on import.
Let's delay removing this metadata until we need to, which has the
advantage that the metadata in our viewer is more complete.
When exporting starts, we add a check in gimp_image_metadata_save_prepare
to see if there was a thumbnail in the EXIF metadata. If not, then we
disable the thumbnail flag.
In gimp_image_metadata_save_filter we remove the thumbnail metadata when
the user doesn't want to save a thumbnail, or when the image format
does not support EXIF.
libgimp/gimpimagemetadata-save.c | 45 ++++++++++++++++++++++++++++++++++------
libgimp/gimpimagemetadata.c | 5 -----
2 files changed, 39 insertions(+), 11 deletions(-)
---
diff --git a/libgimp/gimpimagemetadata-save.c b/libgimp/gimpimagemetadata-save.c
index b35174f28b..0920057a37 100644
--- a/libgimp/gimpimagemetadata-save.c
+++ b/libgimp/gimpimagemetadata-save.c
@@ -270,6 +270,30 @@ gimp_image_metadata_save_prepare (GimpImage *image,
g_date_time_unref (datetime);
g_clear_pointer (&comment, g_free);
+
+ /* EXIF Thumbnail */
+
+ if (gimp_export_thumbnail () && gexiv2_metadata_has_exif (g2metadata))
+ {
+ gchar *value;
+
+ /* Check a required tag for a thumbnail to be present. */
+ value = gexiv2_metadata_try_get_tag_string (g2metadata,
+ "Exif.Thumbnail.ImageLength",
+ NULL);
+ if (! value)
+ {
+ *suggested_flags &= ~GIMP_METADATA_SAVE_THUMBNAIL;
+ }
+ else
+ {
+ g_free (value);
+ }
+ }
+ else
+ {
+ *suggested_flags &= ~GIMP_METADATA_SAVE_THUMBNAIL;
+ }
}
else
{
@@ -283,12 +307,10 @@ gimp_image_metadata_save_prepare (GimpImage *image,
if (! gimp_export_iptc ())
*suggested_flags &= ~GIMP_METADATA_SAVE_IPTC;
- }
-
- /* Thumbnail */
- if (! gimp_export_thumbnail () /* FIXME if (original image had a thumbnail) */)
- *suggested_flags &= ~GIMP_METADATA_SAVE_THUMBNAIL;
+ if (! gimp_export_thumbnail ())
+ *suggested_flags &= ~GIMP_METADATA_SAVE_THUMBNAIL;
+ }
/* Color profile */
@@ -730,7 +752,7 @@ gimp_image_metadata_save_filter (GimpImage *image,
g_strfreev (iptc_data);
}
- if (flags & GIMP_METADATA_SAVE_THUMBNAIL)
+ if (flags & GIMP_METADATA_SAVE_THUMBNAIL && support_exif)
{
GdkPixbuf *thumb_pixbuf;
gchar *thumb_buffer;
@@ -838,6 +860,17 @@ gimp_image_metadata_save_filter (GimpImage *image,
g_object_unref (thumb_pixbuf);
}
+ else
+ {
+ /* Remove Thumbnail */
+ gexiv2_metadata_try_erase_exif_thumbnail (new_g2metadata, &code_error);
+ if (code_error)
+ {
+ g_warning ("%s: failed to erase EXIF thumbnail: %s\n",
+ G_STRFUNC, code_error->message);
+ g_clear_error (&code_error);
+ }
+ }
if (flags & GIMP_METADATA_SAVE_COLOR_PROFILE)
{
diff --git a/libgimp/gimpimagemetadata.c b/libgimp/gimpimagemetadata.c
index 24161be0b1..ee83d649be 100644
--- a/libgimp/gimpimagemetadata.c
+++ b/libgimp/gimpimagemetadata.c
@@ -73,11 +73,6 @@ gimp_image_metadata_load_prepare (GimpImage *image,
metadata = gimp_metadata_load_from_file (file, error);
- if (metadata)
- {
- gexiv2_metadata_erase_exif_thumbnail (GEXIV2_METADATA (metadata));
- }
-
return metadata;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]