> For the complete documentation index, see [llms.txt](https://docs.photoroom.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.photoroom.com/image-editing-api-plus-plan/static-background.md).

# 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](/image-editing-api-plus-plan/ai-backgrounds.md) 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](/image-editing-api-plus-plan/ai-shadows.md) 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&amp;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](broken://pages/xItuUNPEgAlIrn1G1dmE)) 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](/image-editing-api-plus-plan/ai-shadows.md) 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&amp;token=1c7665cf-5c53-4a9b-bb11-71929c283128" alt="" data-size="original">
{% endhint %}


---

# 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.photoroom.com/image-editing-api-plus-plan/static-background.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.
