When I built something similar I used this article quite a bit. But basically you're looking for the EXIF data embedded in the image.
There are a number of great libraries to extract it for you, if you don't want to write it from scratch.
Xenph Yan
2008-11-11 04:34:49