# Inpainting

**Action ID:** `inpainting`

## Description

AI-powered image inpainting that intelligently fills or replaces masked areas in images based on text prompts.

## Connection

| Name               | Description                                 | Required | Category |
| ------------------ | ------------------------------------------- | -------- | -------- |
| PixelML Connection | The PixelML connection to call PixelML API. | True     | pixelml  |

## Input Parameters

| Name       | Type   | Required | Default | Description                                                                                 |
| ---------- | ------ | :------: | ------- | ------------------------------------------------------------------------------------------- |
| prompt     | string |     ✓    | -       | Text description of what to generate in the masked area                                     |
| image\_url | string |     ✓    | -       | URL of the base image. Supported formats: PNG, JPEG, JPG, WEBP                              |
| mask\_url  | string |     ✓    | -       | URL of the mask image defining the area to inpaint. Supported formats: PNG, JPEG, JPG, WEBP |

<details>

<summary>View JSON Schema</summary>

**Input Schema**

```json
{
  "description": "Inpainting node input.",
  "properties": {
    "prompt": {
      "title": "Prompt",
      "type": "string"
    },
    "image_url": {
      "title": "Image url",
      "type": "string"
    },
    "mask_url": {
      "title": "Mask url",
      "type": "string"
    }
  },
  "required": [
    "prompt",
    "image_url",
    "mask_url"
  ],
  "title": "InpaintingNodeInput",
  "type": "object"
}
```

</details>

## Output Parameters

| Name  | Type   | Description                                        |
| ----- | ------ | -------------------------------------------------- |
| image | string | URL of the inpainted image with masked area filled |

<details>

<summary>View JSON Schema</summary>

**Output Schema**

```json
{
  "description": "Inpainting node output.",
  "properties": {
    "image": {
      "title": "Image output",
      "type": "string"
    }
  },
  "required": [
    "image"
  ],
  "title": "InpaintingNodeOutput",
  "type": "object"
}
```

</details>

## How It Works

This node uses advanced AI diffusion models to intelligently fill or replace masked areas in images. You provide a base image, a mask image that defines which areas to modify, and a text prompt describing what you want to generate. The AI analyzes the surrounding context in the base image and generates new content in the masked area that seamlessly blends with the existing image while following your prompt instructions.

## Usage Examples

### Example 1: Remove Unwanted Objects

**Input:**

```
prompt: "green grass and flowers"
image_url: "https://example.com/park-photo.jpg"
mask_url: "https://example.com/person-mask.png"
```

**Output:**

```
image: "https://storage.pixelml.com/inpainted-park.jpg"
```

### Example 2: Add New Elements

**Input:**

```
prompt: "a red sports car parked in the driveway"
image_url: "https://example.com/house.jpg"
mask_url: "https://example.com/driveway-mask.png"
```

**Output:**

```
image: "https://storage.pixelml.com/house-with-car.jpg"
```

### Example 3: Change Background Elements

**Input:**

```
prompt: "blue sky with white clouds"
image_url: "https://example.com/portrait.jpg"
mask_url: "https://example.com/sky-mask.png"
```

**Output:**

```
image: "https://storage.pixelml.com/portrait-new-sky.jpg"
```

## Common Use Cases

* **Object Removal**: Remove unwanted objects, people, or blemishes from photos
* **Background Replacement**: Change backgrounds in product photos or portraits
* **Content Addition**: Add new elements like furniture, decorations, or objects to scenes
* **Image Restoration**: Fill in damaged or missing parts of images
* **Creative Editing**: Modify specific areas of images for artistic or design purposes
* **Product Photography**: Enhance product images by changing backgrounds or adding context
* **Real Estate**: Improve property photos by adding or removing elements

## Error Handling

| Error Type           | Cause                                        | Solution                                                         |
| -------------------- | -------------------------------------------- | ---------------------------------------------------------------- |
| Invalid Image Format | Image format is not supported                | Ensure images are in PNG, JPEG, JPG, or WEBP format              |
| Mask Mismatch        | Mask dimensions don't match image dimensions | Ensure mask image has the same dimensions as the base image      |
| Invalid Mask         | Mask image is not properly formatted         | Use a binary mask with white areas indicating regions to inpaint |
| Prompt Too Vague     | Prompt doesn't provide enough detail         | Provide more specific and descriptive prompts for better results |
| Image Too Large      | Image resolution exceeds maximum limit       | Resize images to a smaller resolution before inpainting          |
| Connection Failed    | Unable to access PixelML API                 | Check PixelML connection credentials and API availability        |
| Processing Timeout   | Operation took too long to complete          | Try with a smaller image or simpler prompt                       |

## Notes

* **Mask Creation**: The mask image should have white areas indicating where to inpaint and black areas to preserve. The mask must have the same dimensions as the base image.
* **Prompt Quality**: More detailed and specific prompts generally produce better results. Describe colors, textures, lighting, and style.
* **Image Resolution**: Higher resolution images may take longer to process. Consider using moderate resolutions for faster results.
* **Context Awareness**: The AI considers the surrounding image context when generating inpainted content for natural blending.
* **Multiple Iterations**: You may need to try different prompts or masks to achieve desired results.
* **Processing Time**: Inpainting typically takes 10-30 seconds depending on image size and complexity.


---

# 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.agenticflow.ai/reference/nodes/inpainting.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.
