• I Cast Fist@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    ·
    14 hours ago

    Simply changing the extension wouldn’t work because each image type has a specific header - even changing a .png to .jpg wouldn’t work - and organizes the actual image data in different ways.

    The header is what actually identifies the file type. For webp, it’s called the RIFF header and it must be 21 bytes (it’s a standardized specification, btw). For jpeg, the header is only 2 bytes and has the values FF D8. In theory, this means that you could even rename the file to image.zip and, if you opened it in an appropriate program, it would read the header and still render it properly