OpenImageIO/oiio — pull request #668 by brechtvl (2013-09-12 13:15:32+00:00)
Title: Fix some JPEG files not being recognized

Now it only looks at the first two bytes. As I understand it there's various markers that may come after those first two bytes. The libjpeg code only seems to require the first two bytes to be 0xff 0xd8, and markers after that do not need to be in a specific order.

Here is on example which has 0xff 0xd8 0xff 0xdb (= DQT marker):
http://www.pasteall.org/pic/show.php?id=59212

I couldn't find many other applications that check for magic numbers, only 'file' and Blender, and those check just the first two bytes.

Also, the previous code that checks for both endian cases is wrong, it could match a file that starts with 0xe0 0xff, but this would not be a valid JPEG file.