You can use object-fit
css3 property, something like
<!doctype html>_x000D_
<html>_x000D_
_x000D_
<head>_x000D_
<meta charset='utf-8'>_x000D_
<style>_x000D_
.holder {_x000D_
display: inline;_x000D_
}_x000D_
.holder img {_x000D_
max-height: 200px;_x000D_
max-width: 200px;_x000D_
object-fit: cover;_x000D_
}_x000D_
</style>_x000D_
</head>_x000D_
_x000D_
<body>_x000D_
<div class='holder'>_x000D_
<img src='meld.png'>_x000D_
</div>_x000D_
<div class='holder'>_x000D_
<img src='twiddla.png'>_x000D_
</div>_x000D_
<div class='holder'>_x000D_
<img src='meld.png'>_x000D_
</div>_x000D_
</body>_x000D_
_x000D_
</html>
_x000D_
It is not exactly your answer, though, because of it doesn't stretch the container, but it behaves like the gallery and you can keep styling the img
itself.
Another drawback of this solution is still a poor support of the css3 property. More details are available here: http://www.steveworkman.com/html5-2/javascript/2012/css3-object-fit-polyfill/. jQuery solution can be found there as well.