The fit parameter in image processing determines how the image should be resized to meet the specified dimensions. There are several options for the fit parameter:
This is the default option when an image dimension is specified using the h and w parameters. The image is resized to the supplied dimensions while other dimensions are altered to maintain the aspect ratio of the input image.
The image is resized to fit the supplied image dimensions and crops any excess. Both h and w needs to be set.
Finds the area around faces in an image and scales it to specified width and height dimensions.
The image is resized to fit within the requested h and w dimensions while preserving the original aspect ratio. Excess space is filled with a solid color. The resulting image matches the supplied dimensions.
h controls the height of the output image in pixels. If only a single dimension is specified, the aspect ratio will be maintained based on the aspect ratio of the input image.
w controls the width of the output image in pixels. If only a single dimension is specified, the aspect ratio will be maintained based on the aspect ratio of the input image.
dpr controls the device-pixel ratio. The dpr parameter causes the w parameters to be treated as device independent pixels (also known as “CSS pixels”). A 400×300 image at dpr=2 will actually be a 800×600 pixel image.