Magic number for google Image Format

Viewed 1992

I am developing (Node.js) my own small procedure to check the file (image) types. So far so good, until I tried to add validation for Google WebP format.

As a guide for Magic Number I have used the file-type library. In their source code they list Magic number for WebP to be (line 45):

0x57, 0x45, 0x42, 0x50

In my library I am using only first two bytes. So I used 0x57 and 0x45 as a reference.

After implementation, I needed a proper image sample. So I dug this out. That is official Google library sample. But the image I downloaded from there, has a different signature. I am getting:

0x52 and 0x49 I also tried to find Magic Number for WebP, but without success. All I was able to find is this Wiki. But it does not provide Magic Number.

Now I hope you understand my dilemma. What information should I use? The one from the file-type library, or take the information from the downloaded image sample from Google?

To summarise the question, should I use:

0x52 and 0x49 (image signature, downloaded from Google)

or

0x57 and 0x45 (sample from image-type library)

or

something entirely else?

1 Answers
Related