[gimp/gimp-2-10] Issue #2209: more accurate magic for HEIF files.



commit e4bff4c8016f18195f9a6229f59cbf41740ddb8d
Author: Jehan <jehan girinstud io>
Date:   Sat Sep 15 11:38:57 2018 +0200

    Issue #2209: more accurate magic for HEIF files.
    
    Just looking for "ftyp" would also match other ISOBMFF files (.mov or
    .mp4 files for instance). These are the possible 4-byte "brand" code
    which can follow "ftyp", as listed by Dirk Farin from libheif.
    
    I add the "mif1" brand, as I encountered some files using this magic
    (even though this should normally not be valid apparently, yet the file
    loaded fine in GIMP).
    
    This is not perfect as the standard allows potentially very big box
    headers, in which case 8 bytes (the "largesize" slot) may be inserted
    between "ftyp" and the brand, as I understand it. But this is actually
    unlikely enough to probably never happen (the compatible brands list
    would have to be huuuge, as it looks like this is the only extendable
    part in a ftyp box). So let's assume this just never happens.
    
    See also: https://github.com/strukturag/libheif/issues/83
    
    (cherry picked from commit 4ad3993eca935854ef2f5664fb77a75c128bbf4d)

 plug-ins/common/file-heif.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/plug-ins/common/file-heif.c b/plug-ins/common/file-heif.c
index 39c8879de5..952a1ffa57 100644
--- a/plug-ins/common/file-heif.c
+++ b/plug-ins/common/file-heif.c
@@ -120,10 +120,19 @@ query (void)
   gimp_register_load_handler (LOAD_PROC, "heic,heif", "");
   gimp_register_file_handler_mime (LOAD_PROC, "image/heif");
   gimp_register_file_handler_uri (LOAD_PROC);
+  /* HEIF is an ISOBMFF format whose "brand" (the value after "ftyp")
+   * can be of various values. I added the "mif1" brand as I saw some
+   * HEIF files with this value, and it loaded fine (though it may not
+   * be valid theoretically, according to libheif developers).
+   * See also: https://gitlab.gnome.org/GNOME/gimp/issues/2209
+   */
   gimp_register_magic_load_handler (LOAD_PROC,
                                     "heif,heic",
                                     "",
-                                    "4,string,ftyp");
+                                    "4,string,ftypheic,4,string,ftypheix,"
+                                    "4,string,ftyphevc,4,string,ftypheim,"
+                                    "4,string,ftypheis,4,string,ftyphevm,"
+                                    "4,string,ftyphevs,4,string,ftypmif1");
 
   gimp_install_procedure (SAVE_PROC,
                           _("Exports HEIF images"),


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