JFIF structure, one of the common formats of JPG Images

Source: Internet
Author: User

Author: Yu Feng
Source: evil baboons Information Security Team (www.eviloctal.com)

The JFIF File Format is the JPEG File interchange Format (JPEG File Interchonge Format ).
A general JFIF file consists of the following nine parts:
(Field offset field length (if "length is not specified", it indicates that the length is the written value under any circumstances) field content (if "the content is not fixed", the content is written in any case. For convenience, you can set the content to a value ))
(1) Start of Image (Start of Image) Marking
0 h 2 bytes 0xFFD8
(2) APP0 tag (Marker)
0 h 2 bytes 0xFFE0
① APP0 length (length) (① ~ ⑨ The total length of nine fields)
2 h 2 bytes of content (① ~ ⑨ The total length of nine fields)
② Identifier)
4 h 5-byte 0x4A46494600 is "j1_0"
③ Version)
9 h 2 byte 0x0102 JFIF versions are basically 1.2
④ Unit of density of X and Y (units = 0: No unit; units = 1: Points/inch; units = 2: Points/cm)
The bh 1 byte is optional only for values 0, 1, and 2. The meanings of these values are as follows:
⑤ X-direction pixel density (X density)
The value range of ch 2 bytes is unknown.
⑥ Y-direction pixel density (Y density)
The value range of the eh 2-byte is unknown.
7. Number of horizontal pixels of a thumbnail (thumbnail horizontal pixels)
The value range of 10 h 1 byte is unknown.
Number of vertical pixels of a thumbnail (thumbnail vertical pixels)
The value range of 11 h 1 byte is unknown.
Batch thumbnail RGB bitmap (thumbnail RGB bitmap)
The length of 12 h may be a multiple of 3.
This section (APP0) can contain a thumbnail version of the image, which is saved as a 24-bit RGB pixel. If there is no thumbnail image
(This is more common), the values of "Number of horizontal pixels in the thumbnail" and "Number of vertical pixels in the thumbnail" are both 0.
(3) APPn tag (Markers), where n = 1 ~ 15 (optional)
① APPn length (length) (① ② Total length of two fields)
② Application specific information)
For each APP:
If it is APPN (N = 1 ~ F (in hexadecimal notation, N can be one of them ))
Mark
Mh 2-byte 0 xFFEN
Length
(M + 2) h 2 bytes (set to n (10 hexadecimal) (the total length of this field and the next field)
Details
(M + 4) h N-2 byte (that is, length minus 2) content is not fixed
(4) One or more quantified tables DQT (Difine Quantization Table)
0 h 2 bytes 0 xFFDB
① Quantization table length (① ~ ② Total length of two fields)
2 h 2 bytes of content (① ~ ② Total length of two fields)
② Quantization table)
A) P/T (four digits higher: precision, four digits lower: Table ID)
B) Table items
For each quantified table:
P/T (four digits higher: precision, four digits lower: Table ID)
1-byte precision of mh. 0 indicates 8 bits, 1 indicates 16 bits, and the value range of ID is 0 ~ 3. Otherwise, the error occurs.
Table item
(M + 1) h (64 X (precision + 1) bytes are long, so
(5) Frame image Start SOF0 (Start of Frame)
0 h 2 bytes 0xFFC0
① Start of frame length (① ~ 6. The total length of the six fields)
2 h 2 bytes of content (① ~ 6. The total length of the six fields)
② Precision, bits per pixel per color component)
4 h, 1 byte, number of digits per sample, usually 8 (most software does not support 12 or 16)
③ Image height)
5 h 2 bytes of content is not fixed (if DNL is not supported, it must be greater than 0)
④ Image width)
7 h 2-byte content is not fixed (if DNL is not supported, it must be greater than 0)
⑤ Number of color components)
9 h 1 byte content is not fixed (grayscale is 1, YCbCr/YIQ color is 3, and CMYK color is 4, we
The JFIF discussed here uses YCbCr, so here the color component number is 3)
6. for each component)
A) ID
B) vertical sample factor)
C) The sample factor (horizontal sample factor) (B) in the horizontal direction occupies 1 byte, and B occupies 4 lower.
(C) occupies 4 digits)
D) quantization table #)
The JFIF format uses YCbCr, so there are three components. (Note that the ID number of the color component is
1 represents Y, 2 represents Cb, 3 represents Cr, 4 represents I, 5 represents Q ):
1) ID
Ah 1 byte 0x01
(Four digits in height) horizontal (four digits in height) Vertical sample factor
Bh in total 1 byte 0x22
Quantization table number
The content of ch 1 byte is not fixed (the idnumber of the quantified table used by this component)
2) ID
Dh 1 byte 0x02
(Four digits in height) horizontal (four digits in height) Vertical sample factor
Eh total 1 byte 0x11
Quantization table number
The 1-byte content of fh is not fixed (the idnumber of the quantified table used in this component)
3) ID
10 h 1 byte 0x03
(Four digits in height) horizontal (four digits in height) Vertical sample factor
11 h total 1 byte 0x11
Quantization table number
12 h 1-byte content is not fixed (the idnumber of the quantified table used by this component)
(6) One or more Hoffmann tables DHT (Difine Huffman Table)
0 h 2 bytes 0xFFC4
① Hoffman table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.