I've submitted this to DA as well.
A client required that thumbnails be generated and placed equidistant from the edges of a square of a given size, depending on the aspect ratio of the image - that is to say that if the image was a landscape then it should be the same width of the square while being placed in the vertical middle. After checking any number of resources I couldn't find an appropriate script so I rolled my own. I'm pretty pleased with it and you're more than welcome to have it from here.
You can view the script as a PDF here.
If you make alterations, and more importantly improvements, please do let me know.
Take it easy.
WOW!!! Gotta get me one of these: