<div class="outer">
<img class="inner" src="https://www.isanxia.com/zb_users/upload/2020/10/202010301604026617513960.jpg" />
</div>
.outer {
display: flex;
align-items: center;
justify-content: center;
border: 1px solid #aaa;
resize: both;
}
.inner {
background-color: green;
aspect-ratio: 4 / 3;
max-height: 100%;
max-width: 100%;
}