Open nathan-osman opened 9 years ago
Actually the 4 bytes in between RIFF and WEBP are file data size for the full payload. So it wouldn't work since that will vary for each file. See https://developers.google.com/speed/webp/docs/riff_container
As I see it the gimp_register_magic_load_handler()
function accepts a pattern where you can define an offset. If I interpret the examples at https://github.com/GNOME/gimp/search?p=3&q=gimp_register_magic_load_handler&utf8=%E2%9C%93 correctly something like 8,string,WEBPVP8
could work. Not sure if there is a way to also test for the leading RIFF
in addition.
I've added it to my branch, adding only the check for WEBP at offset 8 seems enough to me.
Gimp provides plugins with a function
gimp_register_magic_load_handler()
that can be used to select an appropriate loader based on the file contents. It would be nice if this plugin could provide such functionality.The first few bytes of a WEBP image appear to match: