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.
This commit is contained in:
Jacob Boerema 2025-11-03 14:21:53 -05:00
parent 882e45dc63
commit 13d9611719

View file

@ -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)
{