Search code examples
imageencodingpnggifbmp

How to determine an image's encoding


I have an image with a PNG extension.

I suspect it's not really a PNG though (I think it might be a GIF).

How can I confirm an image's encoding?

NB: A solution for Windows would be preferable


Solution

  • You need to do a quick check of the file's internals.

    The first 8 bytes of a PNG image are always

    137 80 78 71 13 10 26 10

    It is vanishingly unlikely that a non-malicious non-PNG has the same 8 bytes.