# AI Relight

## Overview

The Image Editing API allows you to correct lighting issues, such as over-exposition or under-exposition, by re-lighting the input image.

To re-light an image, set the argument `lighting.mode` to either the value:

* `ai.auto` for the lighting to be automatically adjusted
* `ai.preserve-hue-and-saturation` for the lighting to be adjusted while keeping color hues and saturations as close as possible to the original image
  * this can be useful for product images, where maintaining color accuracy is important

{% hint style="warning" %}
Please note that AI Relight is currently limited to images with a maximum resolution of 3,500x3,500 pixels.

Known issue: we don't recommend using AI Relight along with [AI Expand](/image-editing-api-plus-plan/ai-expand.md) in a same API call.
{% endhint %}

## Examples

Here are some examples of what re-lighting can achieve by setting `lighting.mode=ai.auto`:

|            *Original*            |           *Re-lighted*           |
| :------------------------------: | :------------------------------: |
| ![](/files/UFjpoEyX8yAFwZQX46eW) | ![](/files/eD8U6l1fWF98J3KSlPYV) |
| ![](/files/ptYS8RQUFFVoFlthJ6xV) | ![](/files/0aN8xgSDR6zkMbEAgDXz) |
| ![](/files/4M9xgNcftfEyWj6UypRs) | ![](/files/EIArR9mebEP7OoLQkDbd) |

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

{% code overflow="wrap" %}

```bash
curl --request POST \
  --url https://image-api.photoroom.com/v2/edit \
  --header 'x-api-key: YOUR_API_KEY' \
  --form imageFile=@/path/to/your/image.jpg \
  --form referenceBox=originalImage \
  --form maxWidth=2000 \
  --form maxHeight=2000 \
  --form removeBackground=false \
  --form lighting.mode=ai.auto \
  --output with-re-lighting.png
```

{% endcode %}

<a href="https://try-api.photoroom.com/?referenceBox=originalImage&#x26;maxWidth=2000&#x26;maxHeight=2000&#x26;removeBackground=false&#x26;lighting.mode=ai.auto" class="button primary">Try it now!</a>

And here are examples of the output produced by the different values for `lighting.mode`:

### Second-hand marketplace

|            *Original*            |      `lighting.mode=ai.auto`     | `lighting.mode=ai.preserve-hue-and-saturation` |
| :------------------------------: | :------------------------------: | :--------------------------------------------: |
| ![](/files/JMiUSJ4eWn1rbGeoFFdM) | ![](/files/vhLnVuVibIf4ByNanMyD) |        ![](/files/KwsNhGPtcKarRi16hXWn)        |
| ![](/files/bZUGojryKpkA8NgE7jIM) | ![](/files/nA1zm01vS9nlpKKg1V7j) |        ![](/files/Q0z6XPV7rySpmMyqwGyL)        |
| ![](/files/vw42ZXmFgyXLCk2y0jWD) | ![](/files/MLM45V1eQP4FEWtueafW) |        ![](/files/mva6zTADD4RRUR1WbvgF)        |
| ![](/files/36h8qS9eSDEVjEvpRotz) | ![](/files/8IVZP6PpwAsSJsYOxpSQ) |        ![](/files/WdHIws52ZX5GuvqsyYM3)        |
| ![](/files/OOT7z6cf6nHYKlTjTWzb) | ![](/files/OCFyGI6aUkzvcRF1lAuc) |        ![](/files/F5UPS8OOB8PRxkDxz4SB)        |

### School portraits

|            *Original*            |      `lighting.mode=ai.auto`     | `lighting.mode=ai.preserve-hue-and-saturation` |
| :------------------------------: | :------------------------------: | :--------------------------------------------: |
| ![](/files/LNDbj5MFwJnJWnN2Tzdw) | ![](/files/xaNg5DyaJtlBI9BHVeLP) |        ![](/files/sPMsrUsdFrAMXmCSCreI)        |
| ![](/files/AJq0KOd0qU6ijO6T1hkx) | ![](/files/YGXOEZbHFSspCaBvszYf) |        ![](/files/RE75JBYf6PpZYKHDOgDZ)        |
| ![](/files/eC3ehenYqNe4rBhnfvhE) | ![](/files/oINec248RVagHntJ80pe) |        ![](/files/oZHAA89qIkQXf8KNmZj6)        |
| ![](/files/4ZpQPtGETQ7nC87y1ZFH) | ![](/files/PKa91Sv7tnEksYTMR2FW) |        ![](/files/q8iBP0ADBclIltLxPFfT)        |
| ![](/files/PDctLbVAJTLkC64N65Xn) | ![](/files/8cEEqOMzR7yNXRvCxesl) |        ![](/files/I3Os3W878n7XxLFLUKCj)        |
| ![](/files/sVaeU47WFPunnS7cAs3i) | ![](/files/zU9JNb9pYjnKuOyH04mp) |        ![](/files/3Zjj32ebY0COO2bW0TTf)        |

### Food industry

|                              *Original*                             |                       `lighting.mode=ai.auto`                       |            `lighting.mode=ai.preserve-hue-and-saturation`           |
| :-----------------------------------------------------------------: | :-----------------------------------------------------------------: | :-----------------------------------------------------------------: |
| <img src="/files/JMjVCzZhx3LwuSpjm9qx" alt="" data-size="original"> | <img src="/files/UdNjO1WSaa3RjFzzknDS" alt="" data-size="original"> |                   ![](/files/APDwjgfvvI7BcAWiy6Rw)                  |
| <img src="/files/oyGUigTSgEcNzDjW5WAU" alt="" data-size="original"> | <img src="/files/HvTYX0dP70y8ZPgstTMG" alt="" data-size="original"> | <img src="/files/CeR12zAttUPFqnaJMWc1" alt="" data-size="original"> |
| <img src="/files/7kFB99UxlUsrfp0xXWMM" alt="" data-size="original"> | <img src="/files/T9bpZVHcW2f4TGzPbJNO" alt="" data-size="original"> |                   ![](/files/5O1GL93KcwSzAymfnOWO)                  |

### Car industry

|                              *Original*                             |                       `lighting.mode=ai.auto`                       |            `lighting.mode=ai.preserve-hue-and-saturation`           |
| :-----------------------------------------------------------------: | :-----------------------------------------------------------------: | :-----------------------------------------------------------------: |
| <img src="/files/6rDewuFAzyhq8729fno0" alt="" data-size="original"> |                   ![](/files/aFmuBYOJcmNDlmxVi9TB)                  | <img src="/files/fNtcVshWSn9jWIbkLX6J" alt="" data-size="original"> |
| <img src="/files/iUr1APqIQN490BNQaiy5" alt="" data-size="original"> | <img src="/files/XLkP32O50wgsxlCbzw9y" alt="" data-size="original"> |                   ![](/files/fvQqgYesDa8qcuTYXviG)                  |
| <img src="/files/yvNA4vH7diXdmieTlNAt" alt="" data-size="original"> |                   ![](/files/T0RnmdHTg138z1ZLaiJN)                  |                   ![](/files/pzyGIhvXShwcsFYDVnhK)                  |

### Luxury industry

|                              *Original*                             |                       `lighting.mode=ai.auto`                       |            `lighting.mode=ai.preserve-hue-and-saturation`           |
| :-----------------------------------------------------------------: | :-----------------------------------------------------------------: | :-----------------------------------------------------------------: |
| <img src="/files/9TlMpYcOmRnOuOl6qw4I" alt="" data-size="original"> |                   ![](/files/GTlz0aB4KUArZmiyNu8y)                  |                   ![](/files/IKP2ItiRD4IFNHgqu8pL)                  |
| <img src="/files/Jk8po92fU7dSJv1YMTNG" alt="" data-size="original"> | <img src="/files/kqjgFlS4LkxDHA0O6H0s" alt="" data-size="original"> | <img src="/files/taphn7dgWqRTuL2stOMr" alt="" data-size="original"> |
| <img src="/files/e4UvtYJNvVyWb942YULG" alt="" data-size="original"> |                   ![](/files/e2ilzv4Z2aOnfCxuv6vm)                  |                   ![](/files/HwOpDw3uTd2uehRoswXt)                  |


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.photoroom.com/image-editing-api-plus-plan/ai-relight.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
