gimp-webp icon indicating copy to clipboard operation
gimp-webp copied to clipboard

Add magic format string

Open nathan-osman opened this issue 10 years ago • 3 comments

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:

52 49 46 46 B0 EC 00 00 57 45 42 50 56 50 38    RIFF....WEBPVP8

nathan-osman avatar Aug 13 '15 19:08 nathan-osman

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

draekko avatar Aug 08 '16 10:08 draekko

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.

phw avatar Aug 08 '16 10:08 phw

I've added it to my branch, adding only the check for WEBP at offset 8 seems enough to me.

draekko avatar Aug 08 '16 13:08 draekko