Overview of editing images with Imagen

Preview: Using theFirebase AI Logic SDKs to accessImagen models is a feature that's in Preview, which means that it isn't subject to any SLA or deprecation policy and could change in backwards-incompatible ways.

Editing withImagen is only supported if you're using theVertex AI Gemini API. It's also currently only supported for Android and Flutter apps. Support for other platforms is coming later in the year.


Only available when using theVertex AI Gemini API as your API provider.


TheFirebase AI Logic SDKs give you access to theImagen models (via theImagen API)so that you can edit images using either:

  • Mask-based editing, like inserting and removingobjects, expanding image content beyond original borders, and replacingbackgrounds

  • Customization options based onstyle (likepattern, texture, or artist style),subject (like product, person, oranimal), orcontrol (like a hand-drawn sketch).

This page describes each editing option at a high level. Each option has itsown separate page with more details and code samples.

Models that support this capability

Imagen offers image editing through itscapability model:

  • imagen-3.0-capability-001

Note that forImagen models, theglobal location isnot supported.

Mask-based editing

Mask-based editing lets you make localized, precise changes to an image. Themodel makes changes exclusively within a definedmasked area of the image. Amask is a digital overlay defining the specific area you want to edit. Themasked area can either be auto-detected and created by the model or be definedin a masked image that you provide. Depending on the use case, the model mayrequire a text prompt to know what changes to make.

Here are the common use cases for mask-based editing:

Insert objects (inpainting)

You can use inpainting toinsert objectsinto an image.

How it works: You provide an original image and a corresponding masked image — either auto-generated or provided by you — that defines a mask over an area where you want to add new content. You also provide a text prompt describing what you want to add. The model then generates and adds new content within the masked area.

For example, you can mask a table and prompt the model to add a vase of flowers.

Remove objects (inpainting)

You can use inpainting toremove objectsfrom an image.

How it works: You provide an original image and a corresponding masked image — either auto-generated or provided by you — that defines a mask over the object or subject that you want to remove. You can also optionally provide a text prompt describing what you want to remove, or the model can intelligently detect which object to remove. The model then removes the object and fills in the area with new, contextually appropriate content.

For example, you can mask a ball and replace it with a blank wall or a grassy field.

Expand an image beyond its original borders (outpainting)

You can useoutpainting toexpand an image beyond its original borders.

How it works: You provide an original image and a corresponding masked image — either auto-generated or provided by you — that defines a mask of the new, expanded area. You can also optionally provide a text prompt describing what you want in the expanded area, or the model can intelligently decide what will logically continue the existing scene. The model generates the new content and fills in the masked area.

For example, you can change an image's aspect ratio or add more background context.

Replace the background

You canreplace the backgroundof an image.

How it works: You provide an original image and a corresponding masked image that defines a mask over the background — either using automatic background detection or providing the mask of the background yourself. You also provide a text prompt describing what you want to change. The model then generates and applies a new background.

For example, you can change the setting around a subject or object without affecting the foreground (for example, in a product image).

Customization

Customization lets you edit or generate images using text prompts andreference images that guide the model to generate a new image based on aspecifiedstyle,subject (like a product, person, or animal), or acontrol.

Customize based on a style

You canedit or generate images based on a specifiedstyle.

How it works: You provide a text prompt and at least one reference image that shows a specific style (like a pattern, texture, or design style). The model uses these inputs to generate a new image based on the specifiedstyle in the reference images.

For example, you can generate a new image of a kitchen based on an image from a popular retail catalog that you provide.

Customize based on a subject

You canedit or generate images based on a specifiedsubject.

How it works: You provide a text prompt and at least one reference image that shows a specific subject (like a product, person, or animal companion). The model uses these inputs to generate a new image based on the specifiedsubject in the reference images.

For example, you can ask the model to apply a cartoon style to a photo of a child or change the color of a bicycle in a picture.

Customize based on a control

You canedit or generate images based on a specifiedcontrol.

How it works: You provide a text prompt and at least onecontrol reference image (like a drawing or a Canny edge image). The model uses these inputs to generate a new image based on the control images.

For example, you can provide the model with a drawing of a rocket ship and the moon along with a text prompt to create a watercolor painting based on the drawing.


Give feedback about your experience withFirebase AI Logic


Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-03 UTC.