Given some source file (or more generic - input stream), I need to find out
Last time I had to do this, a couple of years ago, the standard API couldn't read EXIF data. This library can do so though:
http://www.drewnoakes.com/code/exif/
Easy answer: Use https://github.com/drewnoakes/metadata-extractor/
If you're crazy/brave/curious, you could get image type from the stream by reading the first few bytes (these are magic numbers). I believe the exif is generally at the start of the stream too.
It's an old thread, but I was doing this recently and found the Apache Tika library useful. Particularly for analysing generic streams to detect what content is in them.
Thought it might help others.
http://tika.apache.org/