# Static Background

## Overview

The Image Editing API allows you to replace the background of the input image with a new static background.

This new static background can be created using either a solid color or another image.

{% hint style="info" %}
If you're looking to create ai-generated background, please check out the [AI Backgrounds](https://docs.photoroom.com/image-editing-api-plus-plan/ai-backgrounds) feature.
{% endhint %}

### Solid Color

To replace the background with a solid color, set the argument `background.color` to an hexadecimal color code (e.g. `FF0000`):

|                                                                                                                     *(original image)*                                                                                                                     |                                                                                                `background.color=D3D3D3`                                                                                               |                                                                                                `background.color=ADD8E6`                                                                                               |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|                    ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FQb4CVQZhXwIcKlzxQ9Qp%2Fshoes.jpeg?alt=media\&token=5369cf82-c842-4444-9ab7-1e749b0c4742)                    | ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FPhrVtKhgOvuxWnClt2Pt%2Fresponse.png?alt=media\&token=e0e88a62-5b4f-4aca-a953-3a09023839f1) | ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FJU4YUMrRQR2TTw1CVSS3%2Fresponse.png?alt=media\&token=fbea7b1c-dbf7-48f1-adc7-ae16d157defe) |
| ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2Fe1Fdc6YnSsUXWr7JzyJu%2Fjonas-kakaroto-KIPqvvTOC1s-unsplash%20Large.jpeg?alt=media\&token=ccb1d7f9-ae15-4427-ab33-56ec7380606e) | ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2Fb8e6O4zmZJ04Atppeqou%2Fresponse.png?alt=media\&token=4a265d58-ecc8-408d-b4bb-24ea5fe36184) | ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FBDCzkEGzsSj4yqdVXhNY%2Fresponse.png?alt=media\&token=c0849b6c-bfa4-4894-88ce-64510b2af248) |

If you want to give it a try, here's the code to reproduce the example above:

```bash
curl --request POST \
  --url https://image-api.photoroom.com/v2/edit \
  --header 'x-api-key: YOUR_API_KEY_HERE' \
  --form imageFile=@/path/to/image.png \
  --form padding=0.1 \
  --form background.color=D3D3D3 \
  --output result.png
```

<a href="https://try-api.photoroom.com/?padding=0.1&#x26;background.color=D3D3D3" class="button primary">Try it now!</a>

{% hint style="info" %}
When replacing the background with a solid color, consider also adding an [AI Shadow](https://docs.photoroom.com/image-editing-api-plus-plan/ai-shadows) for a more visually pleasing result:

<img src="https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2Fut5xoCLbOrePmNx2K0mH%2Fresponse.png?alt=media&#x26;token=bc221098-7718-4f21-84c3-29fe170ddedb" alt="" data-size="original">
{% endhint %}

### Static Image

To replace the background with a static image, set the either the argument `background.imageFile` (available only when [using the `POST` endpoint](https://docs.photoroom.com/image-editing-api-plus-plan/broken-reference)) or `background.imageUrl`:

|                                                                                                                     *(original image)*                                                                                                                     |                                                                                                     *(static image)*                                                                                                     |                                                                                                       *(result)*                                                                                                       |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|                    ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FQb4CVQZhXwIcKlzxQ9Qp%2Fshoes.jpeg?alt=media\&token=5369cf82-c842-4444-9ab7-1e749b0c4742)                    |  ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2F9f5NF9YVpCbRNHX6DVJL%2Ftexture-2.jpg?alt=media\&token=dec785c5-c448-4714-a5a8-cbf851014bfc) | ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2F9ElKTcZhBZSzzPbUwSFT%2Fresponse.png?alt=media\&token=8d92a614-5d31-4321-909b-b3687e08a5ef) |
| ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2Fe1Fdc6YnSsUXWr7JzyJu%2Fjonas-kakaroto-KIPqvvTOC1s-unsplash%20Large.jpeg?alt=media\&token=ccb1d7f9-ae15-4427-ab33-56ec7380606e) | ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FWP5tAoz93Var4UNCj1kl%2Ftexture-1.jpeg?alt=media\&token=d139610d-9c61-4f28-9e23-2a9abe1998ad) | ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2Fds8zVeYY9VT5GWIQlv29%2Fresponse.png?alt=media\&token=9688b6d7-4714-4388-a581-77391a46c97b) |

If you want to give it a try, here's the code to reproduce the example above:

```bash
curl --request POST \
  --url https://image-api.photoroom.com/v2/edit \
  --header 'x-api-key: YOUR_API_KEY_HERE' \
  --form imageFile=@/path/to/image.png \
  --form padding=0.1 \
  --form background.imageFile=@/path/to/background.png \
  --output result.png
```

{% hint style="info" %}
When replacing the background with a static image, consider also adding an [AI Shadow](https://docs.photoroom.com/image-editing-api-plus-plan/ai-shadows) for a more visually pleasing result:

<img src="https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FMNpuFBdeVEictvlAI4iY%2Fresponse.png?alt=media&#x26;token=1c7665cf-5c53-4a9b-bb11-71929c283128" alt="" data-size="original">
{% endhint %}
