Here is how I do with landscape images :
- Create a parent
RawImage
element called "Mask" (works with UI > Image
component too)
- Add the
UI > Mask
component to it
- Put your Smurf image (with the `RawImage component) as a child of the "Mask" object
- Set the values of the child'
RectTransform
:
- Anchors Min = (0.5, 0),
- Anchors Max = (0.5, 1)
- Top = 0
- Bottom = 0
- Add the
Layout > Aspect Ratio Fitter
to the Smurf image and set the Aspect Mode
to "Height Controls Width" and the Aspect Ratio
to the desired value (16/9 for example)
Check the image : Parent called "Mask" and your smurf image called "Image"

For portrait images, the RectTransform
values :
- Anchors Min = (0, 0.5),
- Anchors Max = (1, 0.5)
- Left = 0
- Right = 0
The Aspect Mode
of the child must be set to "Width Controls Heigh"