> For the complete documentation index, see [llms.txt](https://docs.viesus.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.viesus.com/configuration/parameter-reference/background-and-cropping.md).

# Background & Cropping

The Background section (replacement, color substitution, balance) and the AutoCrop section (portrait auto-cropping).

## Background Handling (`Background`)

Background replacement, color substitution, and balance.

<table><thead><tr><th width="125.5999755859375">Parameter</th><th width="91.800048828125">Value</th><th width="95.7999267578125">Default</th><th>Description</th></tr></thead><tbody><tr><td><code>ReplacePath</code></td><td>String</td><td>—</td><td>Path to a <a href="/features/features/background-handling.md">replacement background image</a></td></tr><tr><td><code>backgroundR</code></td><td>0 – 255</td><td>255</td><td><a href="/features/features/background-handling.md">Red component</a> for background color replacement</td></tr><tr><td><code>backgroundG</code></td><td>0 – 255</td><td>255</td><td><a href="/features/features/background-handling.md">Green component</a> for background color replacement</td></tr><tr><td><code>backgroundB</code></td><td>0 – 255</td><td>255</td><td><a href="/features/features/background-handling.md">Blue component</a> for background color replacement</td></tr><tr><td><code>balanceH</code></td><td>-1.0 – 1.0</td><td>0.0</td><td><a href="/features/features/background-handling.md">Hue balance</a> adjustment for background</td></tr><tr><td><code>balanceS</code></td><td>-1.0 – 1.0</td><td>0.0</td><td><a href="/features/features/background-handling.md">Saturation balance</a> adjustment for background</td></tr><tr><td><code>balanceV</code></td><td>-1.0 – 1.0</td><td>0.0</td><td><a href="/features/features/background-handling.md">Value balance</a> adjustment for background</td></tr></tbody></table>

***

## Portrait Auto-Cropping (`AutoCrop`)

Automatic cropping based on facial detection. See [Key Features → Adaptive Auto-Cropping](/discover/key-features.md#adaptive-auto-cropping).

<table><thead><tr><th width="219.2000732421875">Parameter</th><th width="82.2000732421875">Value</th><th width="95">Default</th><th>Description</th></tr></thead><tbody><tr><td><code>HeadYawCoeff</code></td><td>Float</td><td>0.67</td><td>Coefficient for head yaw adjustment</td></tr><tr><td><code>HeadPitchCoeff</code></td><td>Float</td><td>0.75</td><td>Coefficient for head pitch adjustment</td></tr><tr><td><code>HeadroomFixed</code></td><td>0, 1</td><td>1</td><td>Use fixed headroom calculation</td></tr><tr><td><code>HeadroomUnit</code></td><td>Integer</td><td>0</td><td>Headroom unit type</td></tr><tr><td><code>ImageToHeadRatio</code></td><td>Float</td><td>0.48</td><td>Ratio of image to head size</td></tr><tr><td><code>HeadroomLeft</code></td><td>Float</td><td>0.1</td><td><a href="/features/features/portrait-auto-cropping.md">Left side headroom</a></td></tr><tr><td><code>Headroom</code></td><td>Float</td><td>0.1</td><td><a href="/features/features/portrait-auto-cropping.md">General headroom</a></td></tr><tr><td><code>CropModeHeadroom</code></td><td>Float</td><td>0.0</td><td><a href="/features/features/portrait-auto-cropping.md">Headroom for crop mode</a></td></tr><tr><td><code>AspectHeight</code></td><td>Float</td><td>1.0</td><td>Target <a href="/features/features/portrait-auto-cropping.md">aspect ratio height</a></td></tr><tr><td><code>AspectWidth</code></td><td>Float</td><td>1.0</td><td>Target <a href="/features/features/portrait-auto-cropping.md">aspect ratio width</a></td></tr><tr><td><code>PortraitMode</code></td><td>Integer</td><td>2</td><td><a href="/features/features/portrait-auto-cropping.md">Portrait cropping mode</a></td></tr><tr><td><code>AdaptAspectRatioToFace</code></td><td>0, 1</td><td>1</td><td>Adapt aspect ratio based on face detection</td></tr><tr><td><code>AspectRatio</code></td><td>Integer</td><td>0</td><td>Fixed aspect ratio mode</td></tr><tr><td><code>CropMode</code></td><td>0 – 2</td><td>0</td><td><a href="/features/features/portrait-auto-cropping.md">Cropping mode</a> (see <a href="#cropmode-values">CropMode values</a> below)</td></tr></tbody></table>

### `CropMode` values

<table><thead><tr><th width="118">Value</th><th>Description</th></tr></thead><tbody><tr><td><code>0</code></td><td>Manual — uses the configured aspect ratio and headroom values without face-based adjustment</td></tr><tr><td><code>1</code></td><td>Automatic — crops to the dominant detected face using the configured aspect ratio and headroom</td></tr><tr><td><code>2</code></td><td>Group — crops to include all detected faces (for group portraits)</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.viesus.com/configuration/parameter-reference/background-and-cropping.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
