netpbm like MOST software in this category, can be found by doing a search at freshmeat.net.
Yes, netpbm or GD can detect the size of an image, and then produce a NEW image of a smaller size. You can use php or another language to do this.
Search for 'album' or 'photo' at freshmeat for software which uses GD or netpbm. Or, look at the code from gallery:
http://www.menalto.com/projects/gallery/index.php