JPG/JPEG File Format for Pictures

Q

What is JPG/JPEG file format?

✍: FYIcenter.com

A

JPG or JPEG is a short name for Joint Photographic Experts Group, which is a very popular encoding format for storing pictures. JPEG was developed by the Joint Photographic Experts Group committee in 1992, and approved as ISO standard, ISO 10918-1, in 1994.

JPG or JPEG is the file extension for files encoded in JPEG format.

JPEG encoding consists of 5 steps as described at wikipedia.org:

  • The representation of the colors in the image is converted from RGB to YCbCr, consisting of one luma component (Y), representing brightness, and two chroma components, representing color. This step is sometimes skipped.
  • The resolution of the chroma data is reduced, usually by a factor 2. This reflects the fact that the eye is less sensitive to fine color details than to fine brightness details.
  • The image is split into blocks of 8x8 pixels, and for each block, each of the Y, Cb, and Cr data undergoes a discrete cosine transform (DCT). A DCT is similar to a Fourier transform in the sense that it produces a kind of spatial frequency spectrum.
  • The amplitudes of the frequency components are quantized. Human vision is much more sensitive to small variations in color or brightness over large areas than the strength of a high-frequency brightness variations. Therefore, the magnitude of the high-frequency components are stored with a lower accuracy than the low-frequency components. The quality setting of the encoder (for example 50% or 95%) affects to what extent the resolution of each frequency component is reduced. If an excessively low quality setting were to be used, the high-frequency components would be discarded altogether.
  • The resulting data for all 8x8 blocks is further compressed with a loss-less algorithm, a variant of Huffman encoding.

Here are the first 64 bytes of a sample JPEG file dumped in HEX values:

ff d8 ff e0 00 10 4a 46 49 46 00 01 01 01 00 60 ......JFIF......
00 60 00 00 ff e1 31 af 45 78 69 66 00 00 49 49 ......1.Exif..II
2a 00 08 00 00 00 12 00 0e 01 02 00 20 00 00 00 ................
e6 00 00 00 0f 01 02 00 05 00 00 00 06 01 00 00 ................

2013-10-31, 2955🔥, 0💬