How does computer understand whether some file is text, video, image. As it only understands binary at the end of the day ?

316 views

I tried going through various articles and videos available online, but couldn’t really understand, properly!!

In: 0

9 Answers

Anonymous 0 Comments

Basically, the files are constructed following certain standards that include some sort of “header” that tells the computer what they are.

Broken down to a basic level, this is like when we two agree on the following for exchanging files:

– Whenever a file starts with “00”, it’s a text file
– when it starts with “01”, it’s a video
– when it starts with “10”, it’s an image
– when it starts with “11”, something went wrong and that’s not a valid file

In practice, these headers are much longer or course, and pass much more info such as the version of some format used, the encoding for text files (=which bit string corresponds to which symbol), stuff like the resolution and framerate for videos, the filesize and so on.

A common approach to passing the file type specifically is for example the extension: we agree on some filename passed in the header, and whatever is the part of the name after the last period specifies the file type.

You are viewing 1 out of 9 answers, click here to view all answers.