[gimp] Issue #5837: TIFF file not recognized.



commit 9ff02042304fb8c3cfcc05365b9abef6bc64b901
Author: Jehan <jehan girinstud io>
Date:   Mon Nov 16 15:05:15 2020 +0100

    Issue #5837: TIFF file not recognized.
    
    On a provided minimal 1×1px TIFF file, TIFFNumberOfDirectories() seems
    to choke on some missing field and returns 0. I am not sure if the file
    is actually valid or not, but let's make some kind of exception
    (outputting a warning of our own when we do) by assuming there is at
    least 1 page/image in the file when TIFFNumberOfDirectories() returns 0.
    
    Other than this minimal file (which probably has no other interest than
    being a test case), it could actually help salvage corrupted TIFF file
    by attempting to read more data.

 plug-ins/file-tiff/file-tiff-load.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/plug-ins/file-tiff/file-tiff-load.c b/plug-ins/file-tiff/file-tiff-load.c
index 2edd742470..e0ce27ae9d 100644
--- a/plug-ins/file-tiff/file-tiff-load.c
+++ b/plug-ins/file-tiff/file-tiff-load.c
@@ -181,12 +181,14 @@ load_image (GFile        *file,
   pages.n_pages = pages.o_pages = TIFFNumberOfDirectories (tif);
   if (pages.n_pages == 0)
     {
-      TIFFClose (tif);
-      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
-                   _("TIFF '%s' does not contain any directories"),
-                   gimp_file_get_utf8_name (file));
-
-      return GIMP_PDB_EXECUTION_ERROR;
+      /* See #5837.
+       * It seems we might be able to rescue some data even though the
+       * TIFF is possibly syntactically wrong.
+       */
+      pages.n_pages = 1;
+      g_message (_("TIFF '%s' does not contain any directories."
+                   " Attempting to load the file assuming 1 page."),
+                 gimp_file_get_utf8_name (file));
     }
 
   pages.pages = NULL;


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