[gimp/gimp-2-10] plug-ins: fix #7195 Exporting multilayer TIFF with EXIF saves some layers twice



commit a4846a0124cbc926a33d1ed0d915bf3bb13b7e70
Author: Jacob Boerema <jgboerema gmail com>
Date:   Sun Aug 29 16:38:23 2021 -0400

    plug-ins: fix #7195 Exporting multilayer TIFF with EXIF saves some layers twice
    
    If you first open a multi page TIFF, exiv2 generates EXIF tags for the
    first 3 pages in the form of Exif.Image.<tags>, Exif.Image2.<tags>,
    Exif.Image3.<tags>. When exporting with EXIF saving enabled, exiv2 thinks
    it needs to save TIFF pages for the EXIF metadata of the second and third
    page too. Those pages saved by exiv2 contain only metadata no real image
    data and give warnings when loading.
    
    The EXIF tags read from page 2 and 3 are only the basic image specs. We
    don't use those, nor do we add tags to it. Until we support handling of
    metadata for those pages and exiv2 has better support for all TIFF pages
    beyond the first few, I see no reason to save this information.
    
    So for now lets just delete all tags that start with Exif.Image followed
    by a number.

 plug-ins/file-tiff/file-tiff-save.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/plug-ins/file-tiff/file-tiff-save.c b/plug-ins/file-tiff/file-tiff-save.c
index e9bbe3b3f9..4bf8748550 100644
--- a/plug-ins/file-tiff/file-tiff-save.c
+++ b/plug-ins/file-tiff/file-tiff-save.c
@@ -883,6 +883,12 @@ save_metadata (GFile                 *file,
   exif_tags = gexiv2_metadata_get_exif_tags (GEXIV2_METADATA(metadata));
   for (char **tag = exif_tags; *tag; tag++)
     {
+      /* Keeping Exif.Image2, 3 can cause exiv2 to save faulty extra TIFF pages
+       * that are empty except for the Exif metadata. See issue #7195. */
+      if (g_str_has_prefix (*tag, "Exif.Image")
+          && (*tag)[strlen ("Exif.Image")] >= '0'
+          && (*tag)[strlen ("Exif.Image")] <= '9')
+        gexiv2_metadata_clear_tag (GEXIV2_METADATA (metadata), *tag);
       if (g_str_has_prefix (*tag, "Exif.SubImage")
           && (*tag)[strlen ("Exif.SubImage")] >= '0'
           && (*tag)[strlen ("Exif.SubImage")] <= '9')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]