Edit in GitHubLog an issue

Inpainting with Fill Mask

Learn how to use the Fill Masked Areas API in your code workflows by performing the image inpainting task in this guide.

Overview

This guide uses the Fill Masked Areas API to perform an image inpainting task.

Image inpainting is one of the fundamental tasks in computer vision and has many practical applications, such as object removal and manipulation, image re-targeting, image compositing, and 3D effects.

The API accepts an input image and an input mask indicating the hole(s) on the image and returns an image with the hole(s) filled.

About the Fill Masked Areas API

Before getting into the code, let's consider conceptually how the Fill Masked Areas API works at a high level.

  • You begin with a source image, which can be used with one of the supported cloud storage providers.
  • You then provide a masked version of the image. That mask will be where the Photoshop API will add generated content.

Now, let's start the exercise.

Prerequisites

  • Valid credentials. If you don't have them yet, first visit the Firefly Services Getting Started guide to obtain a client_id and client_secret.
  • Node.js installed on your machine and basic familiarity with JavaScript.
  • Store the source and mask images below in a supported cloud storage provider.

Source image

Source image

Mask image

Mask image

Calling the Fill Masked Areas API

Use the v1/mask-objects endpoint first to generate masks to provide in your requests to this endpoint.

A simple example of the request body required to use the API is below:

Copied to your clipboard
{
"image": {
"source": {
"url": "<source_image_url>"
}
},
"masks": [
{
"source": {
"url": "<mask_image_url>"
}
}
]
}

The source of the images, take pre-signed URLs from the cloud storage provider.

Generated result

You can see in the image below that by masking the dog, and then filling that masked area, the API has generated a new image with the dog removed.

Generated Result

Complete sample code

If it's helpful to see a complete implementation, we've provide the full JavaScript code sample.

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2025 Adobe. All rights reserved.