A progressive JPEG image consists of the Scan series. Each scan provides more detailed information for each MCU (more A / C ratios). The first scan usually represents only the DC values ββfor each MCU. This turns out to be the ideal amount of information to get a 1/8 thumbnail image.
In a JPEG file, each scan begins with an SF (start of scan) FFDA marker. To find out how much data is required to complete the first scan, just search the file data to start the second scan (second FFDA marker) and you have the answer. Due to the rules of byte token 2, the byte sequence of FF DA cannot be anything but an SOS token. The compressed data that should encode the FF value, followed by the DA, must be encoded as FF 00 DA.
source share