Fit modes
When an image gets both a width and a height, fit decides how a source of another aspect ratio goes into that box. The same photo of three kittens, wider than tall, asked for as a 480 × 480 square:
<twig:Picasso:Image src="kittens.jpg" width="480" height="480" fit="contain" alt="…" />



| Fit | Keeps the whole image | Output is exactly width × height |
Use it for |
|---|---|---|---|
contain (default) |
yes | no, one side may be shorter | Photos in content, product shots, anything not to cut |
cover / crop |
no, the excess is cut | yes | Cards, avatars, grids of thumbnails of the same size |
fill |
yes | yes, padded with bands | Fixed-size slots where cropping is not an option (logos…) |
Choosing
Section titled “Choosing”- A grid of cards whose images must line up:
crop, and give every image the samewidthandheight. - An avatar:
cropon a square box. - A photo in an article: keep
contain, and give only awidth(the height follows the source ratio), so the browser reserves the right space. - A logo in a fixed slot:
fillkeeps it whole. Prefer a transparent PNG or WebP there: the bands are then transparent rather than white.
Choosing what to keep
Section titled “Choosing what to keep”crop keeps the center of the image. When the subject is elsewhere, say which part to keep in the fit value itself, so no extra prop is needed. Three kittens in a narrow 240 × 480 box: crop keeps the middle one, a focal point picks another:
{# The left kitten sits at 28% of the width and 55% of the height of the photo #}<twig:Picasso:Image src="kittens.jpg" width="240" height="480" fit="crop-28-55" alt="A tabby kitten" />



| Fit | Keeps |
|---|---|
crop-<x>-<y> |
The focal point at x% of the width and y% of the height, as centered as the box allows |
crop-<x>-<y>-<zoom> |
The same, zoomed in (crop-30-20-2 doubles the size of the subject) |
crop-top-left, crop-top, crop-top-right, crop-left, crop-right, crop-bottom-left, crop-bottom, crop-bottom-right |
That side or corner |
The focal point is in percent, not in pixels: it stays right whatever the resolution of the source, so it can be stored once next to the image (an entity field, for example) and passed to every render: fit="crop-{{ photo.focalX }}-{{ photo.focalY }}". Every candidate of the srcset is cut around the same point.
Set the default for every image with default_fit, and override it per image with the fit prop or the fit argument of picasso_image_url().
