Commit 4ad3993e authored by Jehan's avatar Jehan

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
parent 2c6b5c37
......@@ -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"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment