Not sure how I might implement this in to exist code.... So I need to think about that too, but How might it work???
What I have is cut out or an image (my images are hollow on the middle so I need to turn it into a solid.
Method
Magic Wand Background,
invert selection
make work path
Now can I find the center of this work path? Then use this to place the crop tool over its center?
And then begin the center of a crop from there?
I found this, it might be useful although a little to old.
http://forums.adobe.com/message/2376791