How can I constrain an image in a container so that the whole container is filled with as much as the image as possible?

For example (I do not know what size that images will be, this is just an example) - If I have an image container of 100x100 and an image of 600x400, the following conditions would need to be met.

* The image should be displayed at 150x100
* The image should be centred in the container
* The overflow of the image (25px left and right in this example) should be hidden.

***Please note*** - some images will be of greater height than width, so any solution needs to work with images of all sizes, centreing both horizontally and vertically.

Sadly, any solution also has to work with IE9 (as that is the browser that the owners of the intranet I am working on use), so HTML5/CSS3 solutions will not work.

Here are a couple of visual examples -

![Example of image display 1](https://i.stack.imgur.com/7GNz3.png)
![Example of image display 2](https://i.stack.imgur.com/34DP0.png)

I've tried various CSS styles -

* If I nest the `<img>` inside of a `<div>` container then the image
* If I absolutly place the `<img>` over a `<div>` then I am unable to centre it vertically if it is wider than tall (I.e. 600x400).

Any suggestions would be gratefully received.