Well, you can check if the image matches common resolutions and aspect ratios - if there are 307200 pixels, for example, a pretty good guess is that it's 640x480 (or 480x640). You'd need a human to see if the image looks correct - actually, with a simple GUI, it wouldn't take a human very long at all to figure out the correct aspect ratio. This could probably be automated easily enough using some pattern recognition - the "shearing" pattern caused by guessing the width wrong is pretty linear and well-behaving.