http://www.w3.org/ seems to cover a wide range of file format specifications related to the web. For .jpg files you'd want to look up the JFIF specification.

Anyway, google is your friend, and so are 3rd-party libraries.