Check out example codes for "css keep image ratio". It will help you in understanding the concepts better.

Code Example 1

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

Code Example 2

.container {
  padding-top: 75%; /* 
4:3 Aspect 
Ratio (divide 3 by 4 = 0.75)  */
}

Code Example 3

img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

Learn ReactJs, React Native from akashmittal.com