FellowConspirator t1_ixtiuzl wrote
The file name doesn’t have anything to do with the format inside. File extensions serve two purposes: mostly, they are there to help people remember the type of data in the file, and sometimes they are used by the desktop environment to sort files and decide which programs open them.
In fact, the program itself opens the file and checks the data inside the file to figure out what to do with it.
JPEG, GIF, WebP, are all very different. You can name the files whatever you want, but if you look at the first few bytes of data in the file, you can tell right away if you are looking at a JPEG file that’s name ends in .GIF
Implausibilibuddy t1_ixvgvxf wrote
This is why I was able to trick my friends (and myself for a while) into thinking animated jpegs were a thing. I just used to rename the file extension of a gif to .jpg.
Divinate_ME t1_ixun1dt wrote
Yeah no. SPSS recently defaulted to .sav files and is now the standard suggested program for me to open my emulation save files. Something went fucky along the way.
FellowConspirator t1_ixuoatr wrote
Your desktop software (perhaps Windows Explorer), has a database where programs can store an association between a file suffix and a program so that when you double-click on a file, the operating system will use that program. The installer software sets that up. That has nothing to do with the file format — that’s a configuration option of the desktop software.
On MacOS classic, each file had a “resource fork”, which was actually a second hidden file (they exist in version of Windows too, but are mostly unused). The resource fork file contained a code to indicate the file type, and the preferred program to open the file (usually set by the program that created it). The file name was completely irrelevant unless a program was written to filter by name.
Modern macOS would check to see if there was an extension and look up in text files what programs could open them and what the user has as a default. If the extension wasn’t recognized, then it would open the file and read part of it and use that to look up what format the file was (UNIX’ file method). There, the file extension was only important if given, because it was understood to be used by the user to o specify how to sort the files and which programs to use to open it.
Changing the file extension doesn’t change the data inside. If you rename a .jpg file .gif, it’s still a JPEG. If you have a desktop environment configured to open both with the same image editor (say, Photoshop), then double-clicking on the file tells Photoshop to open it. Photoshop then looks at the first few bytes of the file to see what’s inside. If it’s JPEG, it uses a routine to load JPEGs, even if the file has the .gif file extension.
Different formats store information in dramatically different ways, but many programs are capable of reading all sorts of data formats. Sometimes they pay attention to the file name, sometimes they don’t.
Viewing a single comment thread. View all comments