fit
The fit
parameter controls how the image will be constrained within the provided size (width
and height
) values, in order to maintain the correct proportions.
Syntax
fit={value}
Allowed values
Value | Description |
---|---|
bounds | Resize the image to fit entirely within the specified region, making one dimension smaller if needed. |
cover | Resize the image to entirely cover the specified region, making one dimension larger if needed. |
crop | Resize and crop the image centrally to exactly fit the specified region. |
Notes
The fit
parameter has no effect unless both width
and height
are specified.
Examples
Click the links to view the transformed image using a demo Fastly IO service.
Example usage | Description |
---|---|
?width=150&height=150&fit=bounds | Resize the image to fit within the bounds of 150px in width by 150px in height |
?width=150&height=150&fit=cover | Resize the image to entirely cover 150px in width by 150px in height |
?width=150&height=150&fit=crop | Crop the image to 150px in width by 150px in height |