The question is: How can i tell two files apart? One coded with JPEG, another with JPEG2000.
I need format-specific file read/write functions, i can't find file encoding without reading it. JPEG works fine right now, but JPEG func fails to open JPEG2000. So i need to determine whether my file is JPG or JPEG2000.
According to the Digital Formats at Library of Congress, all JPEG 2000 files start with the following signature (also known as magic bytes or magic number):
00 00 00 0C 6A 50 20 20 0D 0A 87 0A
(The IANA record only lists the first 12, so I left the remainder out).
Normal JPEG files on the other hand, starts with:
FF D8 FF E0
Comparing these bytes, you should easily be able to tell them apart.