From 13d96117199d977403d17298b3d469c32e90ca18 Mon Sep 17 00:00:00 2001 From: Jacob Boerema Date: Mon, 3 Nov 2025 14:21:53 -0500 Subject: [PATCH] libgimp: fix #15196 tiff specific exif thumbnail tags copied to jpeg When opening a tiff image with exif metadata including a thumbnail saved in tiff format, the exif metadata of the opened image will include tiff specific metadata like Exif.Image.StripOffsets. These tags are not supposed to be exported to any other formats. Although we removed these tags for the image itself, we forgot to remove them for the thumbnail metadata if adding a thumbnail was selected. Since GIMP itself saves thumbnails in jpeg format, that caused some tags to be left behind when the original software writing the tiff wrote thumbnails in tiff format. We fix this by always removing all thumbnail metadata first before writing our own thumbnail metadata. --- libgimp/gimpimagemetadata-save.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libgimp/gimpimagemetadata-save.c b/libgimp/gimpimagemetadata-save.c index 6365dd8d87..73250f6a85 100644 --- a/libgimp/gimpimagemetadata-save.c +++ b/libgimp/gimpimagemetadata-save.c @@ -898,6 +898,19 @@ gimp_image_metadata_save_filter (GimpImage *image, g_strfreev (iptc_data); } + if (support_exif) + { + /* Remove all old thumbnail metadata: third-party software may have + * written tags we don't expect. */ + gexiv2_metadata_try_erase_exif_thumbnail (new_g2metadata, &code_error); + if (code_error) + { + g_warning ("%s: failed to erase EXIF thumbnail: %s", + G_STRFUNC, code_error->message); + g_clear_error (&code_error); + } + } + if (flags & GIMP_METADATA_SAVE_THUMBNAIL && support_exif) { GdkPixbuf *thumb_pixbuf; @@ -1017,17 +1030,6 @@ 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) {