2020-06-16 2 min read File formats Multimedia Tech explained Teknikal_Domain Unable to load comment count

So everyone knows a JPEG file by it’s extension, .jpg. But look at it with the file tool, and you get something like this:

findcover.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1600x900, frames 3

“JPEG image data, JFIF standard 1.01”. So, what exactly is the difference in these two? And furthermore.. why are we using the wrong name for the file format in the first place?

So here’s the thing: JPEG is not a format. Yes, you heard right, JPEG is not a format for data, it’s an algorithm for lossily compressing image data, but nowhere does it actually describe how to store the resulting data. For that, the original specification proposed the JPEG Interchange Format, or JIF. This format lacked a few features, like specifying the color space or pixel aspect ratio, and also was considered difficult to implement.

Later, we got the JPEG File Interchange Format, or JFIF, which is what’s used today. JFIF is considered simple and lightweight, adding a minimal amount of metadata to the JPEG-produced stream of bits.

Valid extensions for a JFIF file are .jpg, .jpeg, .jpe, .jfif, and .jif. In practice, only the first two are really used. Part of this is what has lead us to calling a “JFIF-formatted file containing JPEG-encoded image data” into “a JPEG image”.

JFIF is pretty flexible in it’s interpretation, and is defined as a series of “segments”, in the same way that PNGs are made of a series of “chunks”. A JFIF file starts with a Start Of Image (SOI) segment, followed by a Start Of Frame (SOF), some Huffman table definitions (DHT), quantization table definitions (DQT), and a scan of image data, representing the raw JPEG bitstream (SOS), followed by an ending trailer (EOI).

The actual format of JPEG data is outside the scope of this post. I might make a post one day, comparing common image file format types and how they’re encoded.

But really that’s about all these is to it, JPEG is just a data compression method, and has nothing to do with the actual file, JFIF is what specifies how we pack that data into a file in a meaningful way that can be read.

comments powered by Disqus