img{
max-height: 600px;
max-width: 600px;
height:auto;
zoom:expression(e){
if(e.width>e.height){
if(e.width>600){
e.height=e.height*(600/e.width);
e.width=600;
}
}else{
if(e.height>600){
e.width = e.width*(600/e.height);
e.height = 600;
}
}e.style.zoom='1';
}(this);
overflow:hidden;
}
<div id='imgbox' style='width:800px;height:800px;border:1px solid #cccccc'>
<img src='3844634748_1496332764.png'>
<img src='3844634748_1496332764.png'>
</div>