Skip to content

feat(genai): Multimodal Image Reference Samples Migration to gemini-2.5-flash-image - #10336

Draft
Kef131 wants to merge 5 commits into
mainfrom
feat-genai-multimodal-image-samples-gemini-flash
Draft

feat(genai): Multimodal Image Reference Samples Migration to gemini-2.5-flash-image#10336
Kef131 wants to merge 5 commits into
mainfrom
feat-genai-multimodal-image-samples-gemini-flash

Conversation

@Kef131

@Kef131 Kef131 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #
b/549909475

  • Migrate 5 controlled/reference image generation samples from deprecated Imagen client.models.editImage to gemini-2.5-flash-image using client.models.generateContent with multimodal Part inputs:
    • ImageGenCannyCtrlTypeWithTextAndImage.java
    • ImageGenRawReferenceWithTextAndImage.java
    • ImageGenScribbleCtrlTypeWithTextAndImage.java
    • ImageGenStyleReferenceWithTextAndImage.java
    • ImageGenSubjectReferenceWithTextAndImage.java
  • Upload generated image bytes directly to the target destination GCS bucket URI using Cloud Storage SDK.
  • Enable and un-ignore all tests in ImageGenerationIT.java, verifying full test suite passes against live Vertex AI.

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended.
  • Tests pass: mvn clean verify required
  • Lint passes: mvn -P lint checkstyle:check required
  • Static Analysis: mvn -P lint clean compile pmd:cpd-check spotbugs:check advisory only

Compliance & Style

  • I have followed Sample Format Guide
  • pom.xml parent set to latest shared-configuration
  • Appropriate changes to README are included in PR
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample

Post-Approval Actions

  • Please merge this PR for me once it is approved

Kef131 added 2 commits August 24, 2026 21:52
- Update ImageGenWithText to use client.models.generateContent with gemini-2.5-flash-image
- Update ImageGenerationIT with configurable bucket, safe cleanup, and testImageGenWithText validation
- Temporarily ignore remaining deprecated Imagen capability tests pending migration
…5-flash-image

- Update Canny, RawReference, Scribble, Style, and Subject reference samples to use client.models.generateContent with multimodal Part inputs
- Upload generated image bytes directly to destination GCS bucket URI
- Enable and un-ignore all tests in ImageGenerationIT
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Aug 24, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates several image generation Java snippets to migrate from the older Imagen models and edit/generate APIs to the new gemini-2.5-flash-image model using the generateContent API. It also updates the integration tests to reflect these changes and improves the cleanup phase. A review comment suggests optimizing ImageGenWithText.java by writing the raw image bytes directly to the file using Files.write instead of decoding and re-encoding them with ImageIO.

Comment thread genai/snippets/src/main/java/genai/imagegeneration/ImageGenWithText.java Outdated
Kef131 and others added 2 commits August 24, 2026 16:05
…hText.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Kef131 Kef131 self-assigned this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant