# Background

The background section contains all background properties, such as removing the background, blurring the background, and setting the color.

### Background removal

Remove image background. This operation offers both fully automated mode and advanced manual options. Following is a description of `remove` option.

**Possible values:**

<table><thead><tr><th width="282.8488754421951">Value</th><th width="107.46975099615454">Type</th><th width="333.506927402293">Description</th></tr></thead><tbody><tr><td>true</td><td>boolean</td><td>Removes image background.</td></tr><tr><td>false</td><td>boolean</td><td><strong>Default</strong>. Keeps the background of the original image intact.</td></tr><tr><td>{ <br>    "category": "general", <br>    "clipping": true <br>}</td><td>object</td><td>Advanced options for background removal. See detailed description in the table below.</td></tr><tr><td>{ <br>    "selective": { <br>        "object_to_keep": "&#x3C;object>" <br>    }, <br>    "clipping": true <br>}</td><td>object</td><td>Advanced options for background removal. See detailed description in the table below.</td></tr></tbody></table>

Below are advanced options supported by `remove`:

<table><thead><tr><th width="212.33333333333331">Option</th><th width="111">Type</th><th>Description</th></tr></thead><tbody><tr><td>category</td><td>string</td><td><p></p><p>Provides a hint about the nature of object in the foreground for a more accurate result of background removal. Possible values: </p><ul><li><code>"general"</code> is suitable for all objects.</li><li><code>"products"</code> is the advanced category that will have better results with product, grocery and food objects. It is used <strong>by default</strong>.</li><li><code>"cars"</code> is the advanced category that will have better results with automotive objects.</li></ul><p>The <code>category</code> background removal option is used by default and cannot be used together with <code>selective</code>.</p></td></tr><tr><td>selective</td><td>object</td><td>Allows to specify exactly which object should remain on the image, e.g. <code>"food"</code>, <code>"sleeping bag"</code>, <code>"product"</code>, etc. Specifying which object to keep is mandatory and should be short and precise.<br>The Selective background removal is an alternative to the <code>category</code> option and cannot be used together.</td></tr><tr><td>clipping</td><td>boolean</td><td><code>false</code> by default. If <code>true</code>, image is clipped to the foreground object bounds. Resulting image canvas is controlled by the <a href="resizing">resizing</a> block. </td></tr></tbody></table>

{% hint style="warning" %}
Please be aware that older versions of the <mark style="color:purple;">`products`</mark> background removal category will be deprecated and automatically updated to the latest version starting January 1, 2025.
{% endhint %}

{% hint style="info" %}
If `clipping` is enabled, `resizing.fit` value is `"crop"/`unspecified, `resizing.width` and `resizing.height`are also unspecified - the resulting cropped image will be scaled to the dimensions of the input image. \
\
If you want to keep the clipped region unchanged, set `resizing.fit` to `"bounds"` and leave `resizing.width` and `resizing.height` unspecified.\
\
You can also upscale or downscale the clipped region in many different ways. See [Resizing](https://docs.claid.ai/image-editing-api/image-operations/resizing) and [Upscale](https://docs.claid.ai/image-editing-api/restorations#upscale) to learn more.
{% endhint %}

{% tabs %}
{% tab title="Simple background removal" %}
**JSON Request**

```json
"operations": {
    "background": {
        "remove": true
    }
}
```

{% endtab %}

{% tab title="Advanced: category" %}

### Category: Products

#### JSON Request

```json
"operations": {
    "background": {
        "remove": {
            "category": "products"
        }
    }
}
```

![](https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2FsVO87EhVXxiXSh5GkpE7%2Fshoes.png?alt=media\&token=119c9c0c-0232-4f67-b9b3-72bcd8026bee)

### Category: Cars

#### JSON Request

```json
"operations": {
    "background": {
        "remove": {
            "category": "cars"
        }
    }
}
```

![](https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2FgewyfAJP7Q6NO4NppWL1%2FBackground%20-%20Remove%20-%20Cars.png?alt=media\&token=c3553f40-62ad-4b87-a3e7-3356b3248f4d)
{% endtab %}

{% tab title="Advanced: selective" %}

#### JSON Request

```json
"operations": {
    "background": {
        "remove": {
            "selective": {
                "object_to_keep": "bottle"
            }
        }
    }
}
```

<figure><img src="https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2Fwu1r4hrlofDC0RZhloQy%2Fimage.png?alt=media&#x26;token=9039dbff-cc6d-4818-93fe-22b92a7f8ae2" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Advanced: clipping and color" %}

#### JSON Request

```json
"operations": {
    "background": {
        "remove": {
            "category": "products",
            "clipping": true
        },
        "color": "transparent"
    }
}
```

![JSON Request](https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2Fx1Cv0cWfwxRuaezJQiLS%2FBackground%20-%20Transperent%20-%20Clipping%20\(2\).png?alt=media\&token=90bbe021-32d9-4fdc-aad8-c7273fecdccf)
{% endtab %}
{% endtabs %}

### Background **color**

The image background. You can set transparent background or any color in hexadecimal format.

**Possible values**

| Value       | Type   | Description                                                                                                                                |
| ----------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| transparent | string | To set transparent background the image format should support an alpha channel (PNG, WEBP or AVIF) otherwise the background will be white. |
| color       | string | Set the color of the background in hexadecimal format. Default is white color.                                                             |

**JSON Request**

{% tabs %}
{% tab title="Transparent" %}

```json
"operations": {
    "background": {
        "remove": {
            "category": "products"
        },
        "color": "transparent"
    }
}
```

![](https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2F4IXCCItiRDFWZHUEFpgA%2FBackground%20-%20Transperent.png?alt=media\&token=373de900-6197-4e90-b9d8-566291fbdb38)
{% endtab %}

{% tab title="Color" %}

```json
"operations": {
    "background": {
        "remove": {
            "category": "products"
        },
        "color": "#C5C6FF"
    }
}
```

![](https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2F84kvz6y9VSKEiZpn6HQM%2FBackground%20-%20Color.png?alt=media\&token=234eafe6-2dba-48ea-a432-abd7833b1c9f)
{% endtab %}
{% endtabs %}

### Background blurring

Blur image background. This operation offers both fully automated mode and advanced manual options. Here's a description of `blur` option.

**Possible values:**

<table><thead><tr><th>Value</th><th width="130">Type</th><th>Description</th></tr></thead><tbody><tr><td>true</td><td>boolean</td><td>Blurs image background</td></tr><tr><td>false</td><td>boolean</td><td><strong>Default</strong>. Keeps the background of the original image intact.</td></tr><tr><td><p>{ <br>    "category": "general",<br>    "type": "regular", <br>    "level": "medium" </p><p>}</p></td><td>object</td><td>Advanced options for background blurring. See detailed description in the table below.</td></tr><tr><td>{ <br>    "selective": { <br>        "object_to_keep": "&#x3C;object>" <br>    }, <br>    "type": "regular", <br>    "level": "medium" <br>}</td><td>object</td><td>Advanced options for background blurring. See detailed description in the table below.</td></tr></tbody></table>

Below are advanced options supported by `blur`:

<table><thead><tr><th width="307">Advanced option</th><th width="130">Type</th><th>Description</th></tr></thead><tbody><tr><td>category</td><td>string</td><td><p></p><p>Provides a hint about the nature of object in the foreground for a more accurate result of background blurring. Possible values: </p><ul><li><code>"general"</code> is suitable for all objects and is used by <strong>default</strong>.</li><li><code>"products"</code>is the advanced category that will have better results with product, grocery and food objects.</li><li><code>"cars"</code> is the advanced category that will have better results with automotive objects.</li></ul><p>The <code>category</code> background blur option is used by default and cannot be used together with <code>selective</code>.</p></td></tr><tr><td>selective</td><td>object</td><td>Allows to specify exactly which object should remain on the image unblurred, e.g. <code>"food"</code>, <code>"sleeping bag"</code>, <code>"product"</code>, etc. Specifying which object to keep is mandatory and should be short and precise. <br>The Selective background blur is an alternative to the <code>category</code> option and cannot be used together.</td></tr><tr><td>type</td><td>string</td><td><p>Selects the type of blur to be applied to the background. </p><p>Possible values: </p><ul><li><code>"regular"</code> is for gaussian blur type. Creates an effect of laying a translucent material like vellum on top of the image background. It is used as <strong>default</strong> parameter.</li><li><code>"lens"</code>is for lens blur type with linear focus. Mimics the blur applied to a photo when a wide aperture is used to achieve a narrow depth of field, so that the foreground objects stands out.</li></ul></td></tr><tr><td>level</td><td>string</td><td><p>Selects the level of blur strength to be applied to the background. Possible values: </p><ul><li><code>"low"</code> is for low blur strength.</li><li><code>"medium"</code> is for medium blur strength. It is used as <strong>default</strong> parameter.</li><li><code>"high"</code> is for high blur strength.</li></ul></td></tr></tbody></table>

**JSON Request**

{% tabs %}
{% tab title="Simple background blurring" %}

```json
"operations": {
    "background": {
        "blur": true
    }
}
```

<figure><img src="https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2FJ466yDUsep1gD7ct41sM%2Fgen.png?alt=media&#x26;token=2a659595-6b84-4455-8604-f5c1ee26b986" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Advanced: category" %}

### Category: Products

####

#### JSON Request

```json
"operations": {
    "background": {
        "blur": {
            "category": "products"
        }
    }
}
```

<figure><img src="https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2FNB7GqNB08VQveiW1SdAU%2F2.png?alt=media&#x26;token=f4b5fa85-6bad-4231-adda-a4a4ac881299" alt=""><figcaption></figcaption></figure>

### Category: Cars

####

#### JSON Request

```json
"operations": {
    "background": {
        "blur": {
            "category": "cars"
        }
    }
}
```

<figure><img src="https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2FjHKwC0RYYR3wNIpNZJbO%2FUntitled.png?alt=media&#x26;token=d2b18d4b-3ee7-4b4c-9198-98ffffcfbadb" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Advanced: selective" %}

#### JSON Request

```json
"operations": {
    "background": {
        "blur": {
            "selective": {
                "object_to_keep": "bottle"
            }
        }
    }
}
```

{% endtab %}

{% tab title="Advanced: type" %}

### Type: Regular

#### JSON Request

```json
"operations": {
    "background": {
        "blur": {
            "category": "cars",
            "type": "regular"
        }
    }
}
```

<figure><img src="https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2FjHKwC0RYYR3wNIpNZJbO%2FUntitled.png?alt=media&#x26;token=d2b18d4b-3ee7-4b4c-9198-98ffffcfbadb" alt=""><figcaption></figcaption></figure>

### Type: Lens

#### JSON Request

```json
"operations": {
    "background": {
        "blur": {
            "category": "cars",
            "type": "lens"
        }
    }
}
```

<figure><img src="https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2F9F9vpRAOTunTrCI6OtBh%2Flens.png?alt=media&#x26;token=c96376cf-6578-4478-a5b3-e824b7f0bc83" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Advanced: level" %}

### Level: low

#### JSON Request

```json
"operations": {
    "background": {
        "blur": {
            "category": "cars",
            "type": "lens",
            "level": "low"
        }
    }
}
```

<figure><img src="https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2FYHflO090VTKy3JV7s3QZ%2Flow.png?alt=media&#x26;token=a62aed39-e424-4f80-a648-96f2129d41a0" alt=""><figcaption></figcaption></figure>

### Level: medium

#### JSON Request

```json
"operations": {
    "background": {
        "blur": {
            "category": "cars",
            "type": "lens",
            "level": "medium"
        }
    }
}
```

<figure><img src="https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2F9F9vpRAOTunTrCI6OtBh%2Flens.png?alt=media&#x26;token=c96376cf-6578-4478-a5b3-e824b7f0bc83" alt=""><figcaption></figcaption></figure>

### Level: high

#### JSON Request

```json
"operations": {
    "background": {
        "blur": {
            "category": "cars",
            "type": "lens",
            "level": "high"
        }
    }
}
```

<figure><img src="https://1549088094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrPciCr3QshdCGkhkBgKD%2Fuploads%2FltUZkupn3TbI8b6FpFKC%2Fhigh.png?alt=media&#x26;token=d688dabd-72e7-42c9-8852-61d8aa1c9dfe" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}
