<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<div class="pane">
<img src="http://i.telegraph.co.uk/multimedia/archive/03235/potd-husky_3235255k.jpg" class="img-responsive"/>
</div>
</div>
</div>
<script>
var max_w=350+'px';
var max_h=250+'px';
$(".pane").each(function(i) {
var this_w=$(this).height();
var this_h=$(this).width();
if (this_w/this_h < max_w/max_h) {
var h = max_h;
var w = Math.ceil(max_h/this_h * this_w);
} else {
var w = max_w;
var h = Math.ceil(max_w/this_w * this_h);
}
$(this).css({ height: h, width: w });
});
</script>