I need a program that will square an out-of-square photo. For some images, I can just rotate, but even then getting the scene precisely level can be tedious. It'd be nice to do it automatically. For other images, the off-square angles might be more complex — a tall building may be distorted. What software can I use to fix this?
If you're referring to rotating a wonky image like I think you are then there are many tools available to you, a good free option being the Gimp (as suggested by Ysap) or ImageMagick if you want to batch rotate many images from the command line.
If you're talking about automatically rotating images to straighten the horizon then I'm afraid the technology isn't quite there yet, see this question:
Gimp has a useful plugin that makes it easy to straighten and crop a misaligned photo (assuming that this is what you really mean)
You can get it here.
All you have to do is trace a line on the photo that should be horizontal and Gimp will rotate the photo until it is horizontal, and optionally crop it.
If by "out of square" you mean non-square / rectangular:
For cropping an image - virtually any photo editor (even Microsoft Paint) will let you crop or cut/paste your image to a square form.
For transforming an image - GIMP (free) and Photoshop ($$) are two powerful but heavy options. Both will do much more than geometry transform or image crop. Well, MS Paint will let you stretch an image as well, but the results will be inferior to what you can get with the former two.
If you're looking to apply this cropping to a lot of images at once and are comfortable using the command line, then give ImageMagick a try. It's a very commonly-used command-line utility for manipulating images.