Something similar to what obtains on sites like imageshack, etc. I Googled it but some of those explanations were Greek to me. I am hoping one of you has a "copy this and voila" sort of script.
I may be able to point you to a freeware script that will do what you want. It is not 100% automatic, you have to define the parameters. You can see it in action at imagegenie. I have made additions to the basic script to make it it work as it does on this site. The basic resize function works fine without those mods. PM me for the source.
Link was sent via PM. Also I meant to mention that I think I have read here on the forums that there is a way to do this using the gd libs files that are now installed on most servers. That might be a better way if you take the time to figure it out.