JPEG structure -------------- Specifications: - Exif: http://www.exif.org/Exif2-2.PDF - JFIF: http://www.w3.org/Graphics/JPEG/jfif3.pdf - JPEG identifier, page 64 (58) - Starts at 0x00. 2 bytes. Value: 0xff 0xd8 - A number of APP markers - Starts at 0x02. Example APP markers: APP1 Exif APP0 JFIF APP0 JFXX APP2 - APP1 Header, page 70 (64) - 10 bytes. Value: Marker Prefix (0xff) APP1 (0xe1) Length of field (2 bytes) The string "Exif" Null (0x00) Padding (0x00) - APP1 TIFF Header, page 16 (10) - Starts at 0x0a from APP1 Header. 8 bytes. Value: Byte order (2 bytes) Fixed (0x002a) (2 bytes) Offset of 0th IFD from start of TIFF header (4 bytes) - IFD Structure, page 19 (13) - Value of 0th IFD (TIFF) starts at 0x0a from APP1 header + offset of 0th IFD. Number of fields (2 bytes) Field Interoperability arrays: 12 bytes each Bytes 0-1: Tag Bytes 2-3: Type 1-BYTE: 8-bit unsigned 2-ASCII: 8-bit container 7-bit ASCII code. NULL terminated. 3-SHORT: 16-bit unsigned. 4-LONG: 32-bit unsigned. 5-RATIONAL: Two LONGs. First one is the numerator, second is denominator. 7-UNDEFINED: 8-bit that can take any value depending on the definition. 9-SLONG: 32-bit signed. 2's complement notation. 10-SRATIONAL: Two SLONGs. First one is the numerator, second is denominator. Bytes 4-7: Count, the number of values Bytes 8-11: Value Offset Offset from the start of the TIFF header to the position where the value is stored. If the value is 4 bytes or smaller, the value itself is stored instead of the offset. Offset to the next IFD (1st IFD, thumbnail) (4 bytes) The offsets to the values of the Exif IFD and GPS IFD is represented as tags in the 0th IFD, named "Exif IFD Pointer" and "GPS Info IFD Pointer" respectively.