Search code examples
cparsingheaderjpeg

Position of width and height in jpeg header structure


I am trying to parse jpeg header where in I need width and height of the frame. I went through many links but am still not clear on the structure. If anyone has concrete idea on the same, please share.

Thanks


Solution

  • The image (aka frame) dimensions are located in the SOF marker. You are looking for either:

    FFC0, 
    FFC1, or
    FFC2
    

    See slide 10 here for the structure

    http://lad.dsc.ufcg.edu.br/multimidia/jpegmarker.pdf

    The values are big endian, so you may have to reverse the bytes on your system.