> ## Documentation Index
> Fetch the complete documentation index at: https://docs.convertly.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Resize, crop & fit

> Width, height, aspect ratio, fit modes, source crop, and smart gravity strategies.

Set `w` and `h` to define the output box. `fit` controls how the source fills that box; `gravity`, `crop`, or `fp` controls where the crop lands when using `fit=cover`.

<Frame caption="Off-centre hero — `gravity=center` (left) vs `gravity=smart` (right).">
  <img src="https://cdn.convertly.sh/cvly/o/convertly-site/docs/cdn-transforms/examples/smart-cropping/gravity-center-vs-smart.webp?v=docs-20260717&format=auto&q=auto:eco" alt="Center vs smart gravity side by side" className="w-full rounded-xl" />
</Frame>

<Frame caption="Manual focal point — `gravity=center` (left) vs `fp=x,y` (right).">
  <img src="https://cdn.convertly.sh/cvly/o/convertly-site/docs/cdn-transforms/examples/smart-cropping/fp-before-after.webp?v=docs-20260717&format=auto&q=auto:eco" alt="Center crop vs focal point crop" className="w-full rounded-xl" />
</Frame>

<Frame caption="Source crop + 16:9 — `?rect=8%,12%,84%,76&w=1200&ar=16:9`.">
  <img src="https://cdn.convertly.sh/cvly/o/convertly-site/docs/cdn-transforms/examples/rect-ar.webp?v=docs-20260717&format=auto&q=auto:eco" alt="Hero cropped with rect and aspect ratio" className="w-full rounded-xl" />
</Frame>

<Frame caption="Wide banner — `?w=1200&ar=21:9&fit=cover`.">
  <img src="https://cdn.convertly.sh/cvly/o/convertly-site/docs/cdn-transforms/examples/ar-wide.webp?v=docs-20260717&format=auto&q=auto:eco" alt="Product photo at 21:9 aspect ratio" className="w-full rounded-xl" />
</Frame>

## Source crop and aspect ratio

Use `rect` to crop the **source** before resize/gravity:

```
?rect=120,80,800,600&w=900&h=600&fit=cover
?rect=10%,15%,80%,70&w=1200&ar=16:9
```

When only one output dimension is set, `ar` derives the other (`w=1200&ar=16:9` → 675px tall).

## Fit strategies

| `fit`             | Behaviour                                                                  |
| ----------------- | -------------------------------------------------------------------------- |
| `cover` (default) | Fills the box, cropping overflow. Pairs with `gravity` for smart cropping. |
| `contain`         | Fits inside the box, padding with transparency.                            |
| `fill`            | Stretches to fill the box.                                                 |
| `inside`          | Scales down without enlarging.                                             |
| `outside`         | Scales to cover on the smallest axis.                                      |

<Frame caption="`fit=cover`">
  <img src="https://cdn.convertly.sh/cvly/o/convertly-site/docs/cdn-transforms/examples/fit-cover.webp?v=docs-20260717&format=auto&q=auto:eco" alt="fit=cover example" className="w-full rounded-xl" />
</Frame>

<Frame caption="`fit=contain`">
  <img src="https://cdn.convertly.sh/cvly/o/convertly-site/docs/cdn-transforms/examples/fit-contain.webp?v=docs-20260717&format=auto&q=auto:eco" alt="fit=contain example" className="w-full rounded-xl" />
</Frame>

<Frame caption="`fit=fill`">
  <img src="https://cdn.convertly.sh/cvly/o/convertly-site/docs/cdn-transforms/examples/fit-fill.webp?v=docs-20260717&format=auto&q=auto:eco" alt="fit=fill example" className="w-full rounded-xl" />
</Frame>

<Frame caption="`fit=inside`">
  <img src="https://cdn.convertly.sh/cvly/o/convertly-site/docs/cdn-transforms/examples/fit-inside.webp?v=docs-20260717&format=auto&q=auto:eco" alt="fit=inside example" className="w-full rounded-xl" />
</Frame>

<Frame caption="`fit=outside`">
  <img src="https://cdn.convertly.sh/cvly/o/convertly-site/docs/cdn-transforms/examples/fit-outside.webp?v=docs-20260717&format=auto&q=auto:eco" alt="fit=outside example" className="w-full rounded-xl" />
</Frame>

## Smart cropping

| Mode                           | When to use                                                           |
| ------------------------------ | --------------------------------------------------------------------- |
| `gravity=auto` (default)       | Fast saliency — best default for most photos.                         |
| `gravity=smart` / `crop=smart` | Content-aware scoring for off-centre subjects.                        |
| `gravity=face`                 | Centres crop on detected faces; falls through to smart if none found. |
| `gravity=entropy`              | Texture-heavy sources with no obvious subject.                        |
| `fp=x,y`                       | Hand-picked focal point — cheapest and deterministic at scale.        |

```
?w=600&h=600&fit=cover&gravity=smart
?w=600&h=400&fit=cover&fp=0.3,0.4
?w=600&h=600&fit=cover&gravity=face
```

<Frame caption="Full-width source before any crop.">
  <img src="https://cdn.convertly.sh/cvly/o/convertly-site/docs/cdn-transforms/examples/original.webp?v=docs-20260717&format=auto&q=auto:eco" alt="Uncropped hero source image" className="w-full rounded-xl" />
</Frame>

<Frame caption="`gravity=face` portrait crop.">
  <img src="https://cdn.convertly.sh/cvly/o/convertly-site/docs/cdn-transforms/examples/gravity-face.webp?v=docs-20260717&format=auto&q=auto:eco" alt="Face-aware crop on a portrait" className="w-full rounded-xl" />
</Frame>

<Frame caption="`gravity=entropy` texture crop.">
  <img src="https://cdn.convertly.sh/cvly/o/convertly-site/docs/cdn-transforms/examples/smart-cropping/gravity-entropy.webp?v=docs-20260717&format=auto&q=auto:eco" alt="Entropy crop on a texture" className="w-full rounded-xl" />
</Frame>

For focal-point workflows, palette extraction, and `/api/images/analyze`, see [Smart cropping & image analysis](/docs/image-cdn/smart-cropping).

## Focal zoom (`fp-z`)

`fp-z` (alias `fpZ`) zooms toward the focal point by shrinking the crop window before resize. Range **1–10**; higher values tighten the crop.

```
?w=900&h=900&fit=cover&fp=0.35,0.4&fp-z=2
```

Pair with `fp=x,y` from [manual focal points](/docs/image-cdn/smart-cropping#manual-focal-points-fpxy) or `/api/images/analyze` for art-directed thumbnails that stay centred on the subject at smaller sizes.

## Device pixel ratio

`dpr` multiplies output pixels while preserving layout size in CSS. Render a 400px slot with `w=400&dpr=2` to receive an 800px asset for Retina displays. Valid range: **1–4**.

```
?w=400&h=300&dpr=2
```

**When to use `dpr` vs `srcset` width descriptors**

| Technique                  | Example                   | Best for                                                                                         |
| -------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------ |
| **`srcset` + `sizes`**     | `320w, 640w, 960w, 1280w` | `<ConvertlyImage>`, most responsive layouts — see [Responsive images](/guides/responsive-images) |
| **`dpr=2` with fixed `w`** | `w=600&dpr=2`             | Density descriptors with Client Hints layouts                                                    |
| **Client Hints**           | `ch=Width,Dpr`            | Browser sends width + DPR — see [Client Hints guide](/guides/client-hints)                       |

You do not need both `dpr=2` and `1200w` in the same `srcset` entry — pick one model per image.
