Search code examples
image-processingjpeg

Byte array of a jpeg header


For a particular reason I am wanting to extract the header info from a jpeg which has been loaded into a byte array.

To find the length of the header I have been comparing the bytes of different jpegs.

The common denominator is that the 1st 623 bytes of each image have the same byte value.

These jpegs are of the same height, width, resolution but of different images/scenes.

Is it really this simplistic? Are the 1st 623 the common header between all assuming that the header does not contain the length of each image in bytes?


Solution

  • There is no "JPEG" header (other than the start of image marker). JPEG is a sequence markers, some of which have following data blocks.

    Various JPEG file formats define formats (e.g. JFIF, XFIF) for APPn markers that identify the file format.

    Your 623 matching bytes could well be the same comment marker written by the same encoder. So, NO you cannot ignore 623 bytes and reliably determine the contents of the file.

    My guess is that it would be in an APPn marker specific to the particular file format or in the Start of Frame marker.