How to know jpeg format without decoding entire image (android)

android, java, jpeg

Solution

From file name extension i.e. *.jpg or *.jpeg

Magic numbers. Most file formats have some special bytes at beginning of file, which denote the type of that file.

Rest of detailed information is interleaved in EXIF data, you will have to read a part of the file for that.

Use Markers which divide file into segments, `0xFF, 0xC0` indicate baseline DCT, `0xFF, 0xC2` indicate progressive DCT. Also, if file has more that one start of scan markers, `0xFF, 0xDA` it is a progressive jpeg. See if you hit these byte sequences in your file.

Problem

Is there any way to on android to know JPEG format without decoding the complete image? By format I mean Baseline, Progressive etc.

Original source