The JFIF (JPEG File Interchange Format) is a standard of file used for storing compressed JPEG image. Usually, the file has popular extension - "jpg". The standard is compatible with JPEG, but it isn't a part of it.
Image data are stored in YCbCr format.
The file is divided into segments. Each segment has two bytes length marker. The first byte of marker is 0xFF, the second is an identificator of the segment type. Table below describes the most important segments.
|0xFFD8||SOI||Start Of Image||Start of file|
|0xFFE0||APP0||Application Segment 0||
This segment contains the following data: identifier which is 0x4A46494600 sequence - 'JFIF' string ended with zero, version, X and Y unit (0-pixel,1-inches, 2-cm), horizontal (X) density, vertical (Y) density, thumbnail horizontal pixel count, thumbnail vertical pixel count, packed (24-bit) values for the thumbnail pixels, n = X thumbnail * Y thumbnail
|0xFFC0||SOF||Start Of Frame||
Includes following informations: data precission (usually 8 bit), width and height of the image, number of components (usually 1-gray or 3-YCbCr, sampling factors, the assignment of the quantization tables to the components)
Define Quantization Table
|Quantization table definition. Usually there is one marker for one table, but there are some exceptions where one marker refers to couple of tables.|
|0xFFC4||DHT||Define Huffman Table||Huffman table definition. Usually, there is one marker for one table, but there are some exceptions where one marker refers to couple of tables.|
|0xFFFE||COM||Comment||String terminated by zero|
|0xFFDA||SOS||Start Of Scan||Includes the following informations: the number of components of the image, the assignments of Huffman tables to the components.|
|0xFFD9||EOI||End Of Image||End of image|