dudul
dudul

Reputation: 43

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

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

Upvotes: 3

Views: 1094

Answers (1)

s.d
s.d

Reputation: 29436

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

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

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

  4. 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.

Upvotes: 9

Related Questions