I have a file that's .gif extension but I suspect that it's a lie and it's actually a webp. What's the best way to know what format the file is?
Asked
Active
Viewed 605 times
2 Answers
2
By looking into file content and checking its magic number. For webp it's WEBP
and for GIF file it is GIF87a/GIF89a
.
Here you have list of all magic numbers and where it is located in file: https://en.wikipedia.org/wiki/List_of_file_signatures

Marcin Orlowski
- 72,056
- 11
- 123
- 141
-
I used the command here to get the magic number https://stackoverflow.com/a/2147527/60117 – ajma Oct 12 '17 at 22:38
-
I could probably mention `file` but for some reason (you know, SO is developers' site ;) I assumed you need to do that from your code yourself. – Marcin Orlowski Oct 12 '17 at 23:06