Do not scale image with the scale of rectangle


I’m trying to do not scale of an image, e.g. if the image is 1080x1920, it must be in that scale without extending. For example,

The image should be in this red rectangle scale and outside of the red lines must be in any color or transparent etc.

Is there any way to do this?

Thanks in advance.