Edit in JSFiddle

<div class="div">
  <img src="https://picsum.photos/500/500" alt="" class="img">
</div>

<div class="div">
  <img src="https://picsum.photos/30/30" alt="" class="img">
</div>
.div {
  width: 200px;
  height: 300px;
  margin: 20px;
  border: 1px solid black;
}

.img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}