[Product News](https://developer.android.com/blog/categories/product-news.md.txt)

# Boost user engagement with AI Image Generation

5 min read ![](https://developer.android.com/static/blog/assets/Android_Blog_banners_dd5c7be5f2_2daQMX.webp) 13 Oct 2025 [![View Thomas Ezan's profile](https://developer.android.com/static/blog/assets/thomas_ezan_d29c7508d0_Z14J7zk.webp)](https://developer.android.com/blog/authors/thomas-ezan.md.txt)[![View Mozart Louis's profile](https://developer.android.com/static/blog/assets/Mozart_Louis_622373dab1_K6xYF.webp)](https://developer.android.com/blog/authors/mozart-louis.md.txt) [Thomas Ezan](https://developer.android.com/blog/authors/thomas-ezan.md.txt) \& [Mozart Louis](https://developer.android.com/blog/authors/mozart-louis.md.txt) Adding custom images to your app can significantly improve and personalize user experience and boost user engagement. This post explores two new capabilities for image generation with Firebase AI Logic: the specialized Imagen editing features, currently in preview, and the general availability of Gemini 2.5 Flash Image (a.k.a "Nano Banana"), designed for contextual or conversational image generation.

**Boost user engagement with images generated via Firebase AI Logic**

Image generation models can be used to create custom user profile avatars or to integrate personalized visual assets directly into key screen flows.

For example, Imagen offers new editing features (in developer preview). You can now draw a mask and utilize inpainting to generate pixels within the masked area. Additionally, outpainting is available to generate pixels outside the mask.
![Imagen inpainting.png](https://developer.android.com/static/blog/assets/Imagen_inpainting_d99f009550_1zs2gh.webp)

*Imagen supports inpainting, letting generate only a part of an image. *

Alternatively, Gemini 2.5 Flash Image (a.k.a Nano Banana), can use extended world knowledge and the reasoning capabilities of the Gemini models to generate contextually relevant images, which is ideal for creating dynamic illustrations that align with a user's current in-app experience.

![In-context nano banana illustration.png](https://developer.android.com/static/blog/assets/In_context_nano_banana_illustration_af21b7247f_1GXGPt.webp)

*Use Gemini 2.5 Flash Image to create dynamic illustrations contextually relevant to your app.*

Finally, the ability to conversationally and iteratively edit images allow users to edit a photo using natural language.

![photo edit natural language.png](https://developer.android.com/static/blog/assets/photo_edit_natural_language_52f7a73044_Z1XbRi9.webp)

*Use Gemini 2.5 Flash Image to edit a picture using natural language.*

When starting to integrate AI to your application, it is important to learn about [AI safety](https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen). It is particularly key to assess your application's security risks, consider adjustments to mitigate safety risks, perform safety testing appropriate to your use case and solicit user feedback and monitor content.

**Imagen or Gemini: The choice is yours**

The difference between [Gemini 2.5 Flash Image](https://ai.google.dev/gemini-api/docs/image-generation) ("Nano Banana") and [Imagen](https://ai.google.dev/gemini-api/docs/imagen) lies in their primary focus and advanced capabilities. Gemini 2.5 Flash Image, as an image model within the larger Gemini family, excels in conversational image editing, maintaining context and subject consistency across multiple iterations, and leveraging "world knowledge and reasoning" to create contextually relevant visuals or embed accurate visuals within long text sequences.

Imagen is Google's specialized image generation model, designed for greater creative control, specializing in highly photorealistic outputs, artistic detail, specific styles, and providing explicit controls for specifying the aspect ratio or format of the generated image.

|---|---|
| **Gemini 2.5 Flash Images** **(Nano Banana 🍌)** | **Imagen** |
| 🌎 world knowledge and reasoning for more contextually relevant images 💬 edit images conversationally while maintaining context 📖 embed accurate visuals within long text sequences | 📐 specify the aspect ratio or format of generated images 🖌️Support of mask-based editing for in-painting and out-painting. 🎚️ greater control over details of the generated image (quality, artistic detail and specific styles) |

Let's see how to use them in your app.  

**Inpainting with Imagen**

A few months ago, we released new editing features for Imagen. Although Imagen is now ready for production for image generation, editing features are still in *developer preview*.

Imagen editing features include *inpainting* and *outpainting*, mask-based image editing features. This new capability allows users to modify specific areas of an image without regenerating the entire picture. This means you can preserve the best parts of your image and only alter what you wish to change.
![Imagen inpainting dog.png](https://developer.android.com/static/blog/assets/Imagen_inpainting_dog_f415940aad_Z2hQmiR.webp)

*Use Imagen editing features to make precise targeted changes in an image and guaranteeing the rest of the image integrity*

These changes are made while maintaining the core elements and overall integrity of the original image and modifying only the area in the mask.

To implement inpainting with Imagen, first initialize `imagen-3.0-capability-001` a specific Imagen model supporting editing features:

```
// Copyright 2025 Google LLC.
// SPDX-License-Identifier: Apache-2.0
val editingModel =
        Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(
            "imagen-3.0-capability-001",
            generationConfig = ImagenGenerationConfig(
                numberOfImages = 1,
                aspectRatio = ImagenAspectRatio.SQUARE_1x1,
                imageFormat = ImagenImageFormat.jpeg(compressionQuality = 75),
            ),
        )
```

From there, define the inpainting function:

```
// Copyright 2025 Google LLC.
// SPDX-License-Identifier: Apache-2.0

val prompt = "remove the pancakes and make it an omelet instead"

suspend fun inpaintImageWithMask(sourceImage: Bitmap, maskImage: Bitmap, prompt: String, editSteps: Int = 50): Bitmap {
        val imageResponse = editingModel.editImage(
            referenceImages = listOf(
                ImagenRawImage(sourceImage.toImagenInlineImage()),
                ImagenRawMask(maskImage.toImagenInlineImage()),
            ),
            prompt = prompt,
            config = ImagenEditingConfig(
                editMode = ImagenEditMode.INPAINT_INSERTION,
                editSteps = editSteps,
            ),
        )
        return imageResponse.images.first().asBitmap()
    }
```

You provide both a sourceImage, a maskImage and a prompt for the edit and the number of edit steps to be performed.

You can see it in action in the [Imagen Editing Sample](https://github.com/android/ai-samples/tree/main/samples/imagen-editing) in the Android AI Sample catalog!

And Imagen also supports *outpainting* that enables you to let the model generate the pixels outside of a mask. You can also use Imagen's Image customization capabilities to change the style of a picture or update a subject in a picture. Read more about it in the [Android developer documentation](https://developer.android.com/ai/imagen#editing).

**Conversational image generation with Gemini 2.5 Flash Image**

One way to edit images with Gemini 2.5 Flash Image is to use the model's multi-turn chat capabilities.

First, initialize the model:

```
// Copyright 2025 Google LLC.
// SPDX-License-Identifier: Apache-2.0

val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
    modelName = "gemini-2.5-flash-image",
    // Configure the model to respond with text and images (required)
    generationConfig = generationConfig {
        responseModalities = listOf(ResponseModality.TEXT,
        ResponseModality.IMAGE)
    }
)
```

To achieve a similar outcome to the mask-based Imagen method described above, we can utilize the `chat` API to initiate a conversation with Gemini 2.5 Flash Image.

```
// Copyright 2025 Google LLC.
// SPDX-License-Identifier: Apache-2.0

// Initialize the chat
val chat = model.startChat()


// Load a bitmap
val source = ImageDecoder.createSource(context.contentResolver, uri)
val bitmap = ImageDecoder.decodeBitmap(source)


// Create the initial prompt instructing the model to edit the image
val prompt = content {
    image(bitmap)
    text("remove the pancakes and add an omelet")
}

// To generate an initial response, send a user message with the image and text prompt
var response = chat.sendMessage(prompt)

// Inspect the returned image
var generatedImageAsBitmap = response
    .candidates.first().content.parts.filterIsInstance<ImagePart>().firstOrNull()?.image

// Follow up requests do not need to specify the image again
response = chat.sendMessage("Now, center the omelet in the pan")
generatedImageAsBitmap = response
    .candidates.first().content.parts.filterIsInstance<ImagePart>().firstOrNull()?.image
```

You can see it in action in the [Gemini Image Chat sample](https://github.com/android/ai-samples/tree/main/samples/gemini-image-chat) in the Android AI Sample catalog and read more about it in the [Android documentation](https://developer.android.com/ai/gemini/developer-api.md.txt#generate-images).

**Conclusion**

Both Imagen and Gemini 2.5 Flash Image offer powerful capabilities, allowing you to select the ideal image generation model to personalize your app and boost user engagement, depending on your specific use case.
Written by:

-

  ## [Thomas Ezan](https://developer.android.com/blog/authors/thomas-ezan.md.txt)

  ###### Senior Developer Relations Engineer

  [read_more
  View profile](https://developer.android.com/blog/authors/thomas-ezan) ![View Thomas Ezan's profile](https://developer.android.com/static/blog/assets/thomas_ezan_d29c7508d0_Z14J7zk.webp) ![View Thomas Ezan's profile](https://developer.android.com/static/blog/assets/thomas_ezan_d29c7508d0_Z14J7zk.webp)
-

  ## [Mozart Louis](https://developer.android.com/blog/authors/mozart-louis.md.txt)

  ###### Developer Relations Engineer

  [read_more
  View profile](https://developer.android.com/blog/authors/mozart-louis) ![View Mozart Louis's profile](https://developer.android.com/static/blog/assets/Mozart_Louis_622373dab1_K6xYF.webp) ![View Mozart Louis's profile](https://developer.android.com/static/blog/assets/Mozart_Louis_622373dab1_K6xYF.webp)
Continue reading
- [![View Thomas Ezan's profile](https://developer.android.com/static/blog/assets/thomas_ezan_d29c7508d0_Z14J7zk.webp)](https://developer.android.com/blog/authors/thomas-ezan.md.txt) 17 Apr 2026 17 Apr 2026 ![](https://developer.android.com/static/blog/assets/Hybrid_inference_solution_for_Android_Blog_1_518db36e12_ZIVyDm.webp) [Product News](https://developer.android.com/blog/categories/product-news.md.txt)

  ## [Experimental hybrid inference and new Gemini models for Android](https://developer.android.com/blog/posts/experimental-hybrid-inference-and-new-gemini-models-for-android.md.txt)

  [arrow_forward](https://developer.android.com/blog/posts/experimental-hybrid-inference-and-new-gemini-models-for-android.md.txt) If you are an Android developer looking to implement innovative AI features into your app, we recently launched powerful new updates.
  [Thomas Ezan](https://developer.android.com/blog/authors/thomas-ezan.md.txt) • 2 min read
- [![View Thomas Ezan's profile](https://developer.android.com/static/blog/assets/thomas_ezan_d29c7508d0_Z14J7zk.webp)](https://developer.android.com/blog/authors/thomas-ezan.md.txt) 17 Dec 2025 17 Dec 2025 ![](https://developer.android.com/static/blog/assets/gemin3flash_d6f3bd27b1_2pRpOz.webp) [Product News](https://developer.android.com/blog/categories/product-news.md.txt)

  ## [Build smarter apps with Gemini 3 Flash](https://developer.android.com/blog/posts/build-smarter-apps-with-gemini-3-flash.md.txt)

  [arrow_forward](https://developer.android.com/blog/posts/build-smarter-apps-with-gemini-3-flash.md.txt) Today, we're expanding the Gemini 3 model family with the release of Gemini 3 Flash, frontier intelligence built for speed at a fraction of the cost.
  [Thomas Ezan](https://developer.android.com/blog/authors/thomas-ezan.md.txt) • 2 min read
- [![View Michelle Martin's profile](https://developer.android.com/static/blog/assets/unnamed_29_8358471ffe_MSkhy.webp)](https://developer.android.com/blog/authors/michelle-martin.md.txt) 10 Nov 2026 10 Nov 2026 ![](https://developer.android.com/static/blog/assets/ABL_Sign_in_with_Google_Plugin_for_Unity_Gaming_DESIGN_Header_and_metadata_V01_26433b75fe_Z260GOa.webp) [Product News](https://developer.android.com/blog/categories/product-news.md.txt)

  ## [Powering Seamless Player Sign-In: Introducing the Open-Source Sign in with Google Plugin for Unity](https://developer.android.com/blog/posts/open-source-google-sign-in-unity.md.txt)

  [arrow_forward](https://developer.android.com/blog/posts/open-source-google-sign-in-unity.md.txt) With Unity powering over half of all mobile titles worldwide, first impressions matter. For game developers, a smooth, reliable player onboarding experience is essential to driving day-one retention and long-term engagement.
  [Michelle Martin](https://developer.android.com/blog/authors/michelle-martin.md.txt) • 1 min read
Stay in the loop


Get the latest Android development insights delivered to your inbox
weekly.
[mail
Subscribe](https://developer.android.com/subscribe) ![A 3D illustration of the Android mascot, wearing a jetpack that's emitting a large cloud of bubbles](https://developer.android.com/static/blog/assets/rocket-android.CVJQZOf1_1zVtXW.webp)