Usually in the file header most image files have an 'id' or 'magic number' to confirm that it truly is a jpg/tif/tga/png etc, often in the first couple of bytes.
I've written some code for reading in uncompressed TIFFs and TGAs - most file formats are easy enough to read if they're uncompressed or compressed with a fairly simple method like RLE.
Also in the header they always contain a reference to the width and height and of an image along with lots of other information.
Have a look on google under 'jpg file specification' or similar. Reading the header is usually pretty easy.
I've written some code for reading in uncompressed TIFFs and TGAs - most file formats are easy enough to read if they're uncompressed or compressed with a fairly simple method like RLE.
Also in the header they always contain a reference to the width and height and of an image along with lots of other information.
Have a look on google under 'jpg file specification' or similar. Reading the header is usually pretty easy.