---
title: "Generative Fill: How AI Fills a Selection - CE.SDK Glossary"
description: "Generative fill uses AI to add, remove or replace what sits inside a selection. See how it works, how it differs from content-aware fill, and where CE.SDK fits."
url: "https://img.ly/glossary/generative-fill/"
type: "page"
---

> This is the markdown version of [Generative Fill: How AI Fills a Selection - CE.SDK Glossary](https://img.ly/glossary/generative-fill/). For all pages in one file, see [llms-full.txt](https://img.ly/llms-full.txt). For an index of all available pages, see [llms.txt](https://img.ly/llms.txt).

---

# Generative Fill

## What Is Generative Fill?

Generative fill replaces whatever is inside a selected area of an image with new pixels drawn by an AI image model. A text prompt says what should appear there, and with the prompt left blank, the model fills the area from what surrounds it, which is how most removals are done.

Adobe introduced the name in May 2023 with a Photoshop beta built on its Firefly models, and Cloudinary uses it for an API feature that pads an image to a new aspect ratio and fills the padding.

## How Does Generative Fill Work?

Generative fill tools share one loop, from drawing the selection to keeping the version that fits best.

### 1: Select the area to change

The selection marks what the model is meant to replace, from a rough lasso around a tourist to a precise mask around a person. Everything outside it is context the model reads but should leave alone.

### 2: Name what should appear

When adding or replacing, a short, specific prompt works best. "Red canoe pulled up on the sand" gives the model a clear target where "boat" could come back as almost anything, and a long, elaborate sentence rarely beats a few precise words.

### 3: Let the model generate the fill

The model reads the pixels around the selection and generates content that matches their lighting and perspective. How long that takes depends on the model: when IMG.LY timed 26 models generating an image from a prompt in its [AI benchmark](https://img.ly/ai-benchmarks.md), the median ran from 2 seconds to over 2 minutes.

### 4: Choose one of the results

Each run comes out different, so tools usually return several versions to compare. If none of them fits, generating again with the same selection and prompt gives a fresh set.

## What Can You Do With Generative Fill?

One tool covers four jobs, and what you select and type changes with each. Filling the blank canvas past an image's edge is also called outpainting, and Photoshop gives it a separate tool, Generative Expand.

- **Remove an object**: What to select: The object, its shadow and a margin, What to type: Nothing

- **Add an object**: What to select: The spot where it should go, What to type: The object to add

- **Replace a background**: What to select: Everything behind the subject, What to type: The new setting

- **Extend the frame**: What to select: The empty canvas past the edge, What to type: Nothing, or the scene

## How Is Generative Fill Different From Content-Aware Fill?

Both can remove an object from a photo, but they get the replacement pixels from different places.

### Content-aware fill copies from the photo

Photoshop has offered content-aware fill since CS5 in 2010. It rebuilds the selection from pixels found elsewhere in the same image, which works well on sky, grass or a plain wall. The copied pieces can repeat, though, so a distinctive object next to the selection may turn up twice, and on buildings, crowds and other structured scenes the pattern breaks or smears.

### Generative fill creates new pixels

Generative fill pastes in nothing from the photo itself. Its model draws every pixel of the selection, so it can rebuild a background the object was hiding or add an object the photo never had. The result is the model's best guess at what belongs there, so the small details are worth a closer look before you keep it.

## How Do You Get Better Generative Fill Results?

Most failed fills come down to the selection, the source image or a detail that image models still draw badly.

### Select a little more than the object

Include its shadow, any reflection and some of the background around it, so no trace of the object is left at the edges.

### Work on one small area at a time

Large selections tend to come back softer than small ones, and a low-resolution photo gives a blurry fill. Remove two objects in two passes.

### Check faces, hands and text

These are the hardest details for a fill to get right: hands and faces can come out distorted, and lettering garbled. Text accuracy varies by model, and 15 of the 26 in IMG.LY's text-to-image benchmark got at least one required string wrong. Zoom in before keeping a result.

## How AI Photo Editing Works in CE.SDK

Your users remove, add and replace by writing what should change, and an image editing model applies it to the photo they selected.

### Step 01: Describe the edit for a selected photo

On the web, image edits sit in the canvas menu of a selected photo. On iOS and Android, an Edit button in the inspector bar takes the prompt. The instruction and the photo go to an [image editing model](https://img.ly/use-cases/ai-editor/image-to-image.md), which sends back the edited version.

### Step 02: Name the object in the instruction

Users write which object should go or come, and the model finds it in the photo, as the [Add & Remove Objects](https://img.ly/use-cases/ai-editor/add-remove-objects.md) page shows. On the web, a separate action replaces the background of the selected photo from a prompt.

### Step 03: Choose the model behind the edit

On iOS and Android, edits go to the [IMG.LY AI Gateway](https://img.ly/ai-gateway.md), where FLUX.2 is the default and GPT Image 2 can replace it. In IMG.LY's benchmark, which tested generation from a prompt and not editing, GPT Image 2 came closest of all 26 models to requested brand colors. On the web, you choose which of the Gateway's image editing models handles it, or connect a provider of your own.

## FAQs

### Generative Fill

**Q: How does generative fill relate to inpainting?**

A: Inpainting is the general technique of filling a missing or masked part of an image. Generative fill is a product feature built on AI inpainting, and when the selection reaches past the edges of the image, the same idea is called outpainting.

**Q: Does generative fill change the rest of the image?**

A: It is meant to change only the selection, but the model blends the new content into its surroundings, so a fill can spread a little past the selection edge. In Photoshop the result sits on its own layer, and hiding or deleting that layer brings the original back.

**Q: Can generative fill change an image's aspect ratio?**

A: Yes, by extending it. Widen the canvas, select the empty strip, and the model continues the scene into it, which can turn a tall photo into a wide one. Results get weaker as the new area grows, because the model has less of the original to go on.

## Links

- [Image to Image](https://img.ly/use-cases/ai-editor/image-to-image.md): Let users change a selected photo by describing the edit.
- [Add & Remove Objects](https://img.ly/use-cases/ai-editor/add-remove-objects.md): Take objects out of a photo or put new ones in by naming them.
- [Image Models on the Web](https://img.ly/docs/cesdk/js/user-interface/ai-integration/image-generation-0540d9.md): Connect the image-to-image models behind the edit actions.

---

## More Resources

- **[IMG.LY Website](https://img.ly/index.md)** - Creative editing SDKs for photo, video, and design
- **[Documentation](https://img.ly/docs/cesdk/)** - CE.SDK developer documentation
- **[Build with a coding agent](https://img.ly/SKILL.md)** - A skill that adds a CE.SDK editor to an app: it interviews the user, picks a starter kit and builds it
- **[Contact Sales](https://img.ly/forms/contact-sales.md)** - Get a custom quote. A public JSON API accepts the request directly, no account or key needed. Ask your user for consent and their details first.
- **[Free Trial](https://img.ly/pricing.md)** - Start building with CE.SDK
