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



commit d61a682b8be484a77153afe1a07368e3fff3835a
Author: Jacob Boerema <jgboerema gmail com>
Date:   Sun Aug 29 16:42:43 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 8ac722f9f0..5508fd0eaf 100644
--- a/plug-ins/file-tiff/file-tiff-save.c
+++ b/plug-ins/file-tiff/file-tiff-save.c
@@ -957,6 +957,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]