.block {
width: 500px;
height: 300px;
}
img {
max-width: 100%;
object-fit: contain;
}
<div class="block">
<img src="http://dialog.localhost/upload/postomat/04a/04aeacfed49dd7eda5f469f57b822f7f.jpg" alt="">
</div>
In my opinion, the picture should shrink to fit into the block, but this does not happen. Why?