JPG segment length coding

I am trying to write code to extract Exif information from a JPG.

Exif is stored in the APP1 segment of the JPG file. According to the Exif specification , the APP1 segment format should start as follows:

FF E1        // APP1 segment marker
nn nn        // Length of segment
45           // 'E'
78           // 'x'
69           // 'i'
66           // 'f'

And this happens until it is FFfollowed by something other than FFor 00.

Looking at the JPG in a hex editor, I see the string FF E1and Exif, but I am unable to decode the length bytes. Example: in one jpg, my hex editor tells me that the APP1 segment is 686 bytes long, but bytes long F7 C8.

How should I use these bytes to print a number from 686?

Edit: Here is the first part of the sample file:

FF D8 FF E1 F7 C8 45 78 69 66 00 00 4D 4D 00 2A 00 00 00 08

: , , , . APP1 "" ? , APP1, . - ?

+3
2

, APP1 (. EXIF ​​ 12), 686 - (, ). F7C8 - DQT, , .

+3

. 686, "Exif".

. , 20 .

+1

Source: https://habr.com/ru/post/1739550/


All Articles