For instance, if I need to fill a bounding box that is 100px wide by 50px tall, the following input images would have the following behavior:
200w x 200h gets scaled down 50% and 25% gets chopped off the top and bottom.
200w x 100h gets scaled down 50% with no cropping.
100w x 200h gets is not scaled, but 75px get chopped off top and bottom.
This seems like it'd be a common resizing function, but I haven't been able to track down an example of the algorithm.
Will accept answer in any language including pseudo code. A link to a page with the answer is great too!