Is this the function of a file format?

501 views

I have trouble understanding file formats, or maybe I have figured it out. Please help me!

A file format is a specification that tells how the data of a file is arranged and thus how it is to be interpreted. Does this mean, for instance, that data arranged according to a JPEG (an image format and codec) will tell my computer that the data is to be interpreted as an image?

In: 16

16 Answers

Anonymous 0 Comments

>for instance, that data arranged according to a JPEG (an image format and codec) will tell my computer that the data is to be interpreted as an image?

No.
Your computer has no idea what format the data actually is. The extension (.mp3, .txt, etc) is the thing that tells your computer what the data is.
You can immediately see this by renaming the extension of a say an .mp3 files as a .txt.
The computer will immediately try reading it as a .txt files, and produces utter gibberish as a result.
So there is no way for the file format itself to tell the computer how to read it, other than a convention to name files a certain way.

You are correct, that once the computer is directed to use a compatible program, it will work, because the file maker program and the file reader program share an idea of what way the files should be.

Think of a file format more like a form.
So imagine it like saying
“Last Name 10 letters, First Name 10 letters, Occupation 10 letters”

The file might look like
“Smith00000John000000Plumber00”

So if you got the right program to access it, it would read A Plumber named John Smith.

Use the wrong program… say one that’s expecting
“Occupation 15 letters, Last Name 15 letters, First Name 15 letters”

And it would tell you there’s someone named 0000Plumber00 who works as a Smith00000John.

Some formats are complicated enough that a wrong format is enough to break everything, so those will tell you the format is corrupted.

EDIT:
OK I think I see the problem here.
There are two groups of people here. Those that see the OS and Applications as two very different things, and those who don’t make that distinction.

If you see the OS as a different, you know that files are just a sequence of bytes and it’s up to the program to figure out what those bytes mean. So the OS has no idea what the file contents really mean, it just hands it off to a program that it thinks should (guided by the file extension), or serves up whatever file a program ask for.
So from that perspective, the OS doesn’t know anything about file formats.

If you don’t see a difference, then you know that some programs have ways of detecting if a file is a format they were specifically designed to read. In addition, some programs which are designed to handle multiple formats can recognize certain features in a file and can thus figure out what format it is.
So they think that the contents of the file matter.

However I would like to immediately point out that some programs (such as basic text editors) have a such a broad range, that they’ll be able to read something from nearly any file, regardless of format, because nothing in the chain from drive to screen actually knows anything about file formats. So despite it displaying gibberish, it still shows something.

Anonymous 0 Comments

>for instance, that data arranged according to a JPEG (an image format and codec) will tell my computer that the data is to be interpreted as an image?

No.
Your computer has no idea what format the data actually is. The extension (.mp3, .txt, etc) is the thing that tells your computer what the data is.
You can immediately see this by renaming the extension of a say an .mp3 files as a .txt.
The computer will immediately try reading it as a .txt files, and produces utter gibberish as a result.
So there is no way for the file format itself to tell the computer how to read it, other than a convention to name files a certain way.

You are correct, that once the computer is directed to use a compatible program, it will work, because the file maker program and the file reader program share an idea of what way the files should be.

Think of a file format more like a form.
So imagine it like saying
“Last Name 10 letters, First Name 10 letters, Occupation 10 letters”

The file might look like
“Smith00000John000000Plumber00”

So if you got the right program to access it, it would read A Plumber named John Smith.

Use the wrong program… say one that’s expecting
“Occupation 15 letters, Last Name 15 letters, First Name 15 letters”

And it would tell you there’s someone named 0000Plumber00 who works as a Smith00000John.

Some formats are complicated enough that a wrong format is enough to break everything, so those will tell you the format is corrupted.

EDIT:
OK I think I see the problem here.
There are two groups of people here. Those that see the OS and Applications as two very different things, and those who don’t make that distinction.

If you see the OS as a different, you know that files are just a sequence of bytes and it’s up to the program to figure out what those bytes mean. So the OS has no idea what the file contents really mean, it just hands it off to a program that it thinks should (guided by the file extension), or serves up whatever file a program ask for.
So from that perspective, the OS doesn’t know anything about file formats.

If you don’t see a difference, then you know that some programs have ways of detecting if a file is a format they were specifically designed to read. In addition, some programs which are designed to handle multiple formats can recognize certain features in a file and can thus figure out what format it is.
So they think that the contents of the file matter.

However I would like to immediately point out that some programs (such as basic text editors) have a such a broad range, that they’ll be able to read something from nearly any file, regardless of format, because nothing in the chain from drive to screen actually knows anything about file formats. So despite it displaying gibberish, it still shows something.

Anonymous 0 Comments

All files are just long strings of 1s and 0s.

You need to tell the computer what to do with those 1s and 0s. Should they be interpreted as a text file? Some sort of image? Maybe a sound file? Or a video? Or maybe as a program to be executed?

You can open a file meant to describe an image in a music player or a text editor but you will just get garbage.

When human write things down you can tell just from looking at what is written what the writing is supposed to be about. Is it a french poem, a recipe in Italian, as shopping list in English?

You can try to interpret a text that is a songs lyrics as washing instructions for your clothes washer, but it won’t really get you very far.

You won’t need to be told, you can tell by looking at it. If you get a letter written in a language you can’t read you can at least work towards getting help from someone who can read Chinese or Arabic to tell you what it is about and go from there.

Computers are not that flexible. You need to tell them exactly what you give them and what to do with it.

There are many ways to do that but the one you would use in for example Windows would be to add a a code at the end of the filename like “.txt” or “.jpeg” to let the operating system know what it is and what to do with it.

You can open basically any file on your computer with a hex-editor. This will give you access to the data in the file in its most raw format.

A text file will be readable almost right away, but other formats less so.

Often the beginning or files contain certain information about what type of file they are.

Many modern file formats are XML based (similar to the way the dat for this very website is arranged), this is not always the most efficient way to put data in a file but it makes it more human readable.

There are even some graphics formats like SVG that work like this and can be opened in a text editor to make sense of them.

Most of the time though file formats will only work for the program they are intended for.

Anonymous 0 Comments

All files are just long strings of 1s and 0s.

You need to tell the computer what to do with those 1s and 0s. Should they be interpreted as a text file? Some sort of image? Maybe a sound file? Or a video? Or maybe as a program to be executed?

You can open a file meant to describe an image in a music player or a text editor but you will just get garbage.

When human write things down you can tell just from looking at what is written what the writing is supposed to be about. Is it a french poem, a recipe in Italian, as shopping list in English?

You can try to interpret a text that is a songs lyrics as washing instructions for your clothes washer, but it won’t really get you very far.

You won’t need to be told, you can tell by looking at it. If you get a letter written in a language you can’t read you can at least work towards getting help from someone who can read Chinese or Arabic to tell you what it is about and go from there.

Computers are not that flexible. You need to tell them exactly what you give them and what to do with it.

There are many ways to do that but the one you would use in for example Windows would be to add a a code at the end of the filename like “.txt” or “.jpeg” to let the operating system know what it is and what to do with it.

You can open basically any file on your computer with a hex-editor. This will give you access to the data in the file in its most raw format.

A text file will be readable almost right away, but other formats less so.

Often the beginning or files contain certain information about what type of file they are.

Many modern file formats are XML based (similar to the way the dat for this very website is arranged), this is not always the most efficient way to put data in a file but it makes it more human readable.

There are even some graphics formats like SVG that work like this and can be opened in a text editor to make sense of them.

Most of the time though file formats will only work for the program they are intended for.

Anonymous 0 Comments

Are you asking about the file format or the extension?

Anonymous 0 Comments

Are you asking about the file format or the extension?