Fit

Fits the image in a box with padding when needed

Resizes the image to fit into a specified width and height box, adds padding (image or solid color) to keep proportions, and delivers the resulting image via CDN.

func=fit

Please note that by default, smaller images will not be upscaled to fit the box. If you want to enable this behavior, you need to use fit_enlarge=1. along with func=fit.

The padding can be customized using the following additional operations:

Operation
Syntax
Description

gravity

gravity=X X=[north|south][east|west]

sets the position of the image in the fit box

solid background

bg_color=X | bg_colour=X X={hex color}|auto

defines a background color with a hex code, color name or automatically, based on the image palette

blurred background

bg_img_fit=1

sets blurred image background

bg_blur=X

applies Gaussian blur to the background image

bg_opacity=X X=0..1

specifies background image opacity

bg_colorize=X | bg_colourise=X

defines a color to tint the background image

bg_gravity=X X=[north|south][east|west]

defines the positioning of the background image within its container

image upscaling

fit_enlarge=1

allows upscaling smaller images to the desired dimensions (will result in inferior image resolution)

Gravity

northwest

north

northeast

west

center | centre (default)

east

southwest

south

southeast

Examples

Last updated

Was this helpful?