Pass through provider specific Gemini image aspect ratios#282
Open
morcken wants to merge 1 commit intolaravel:0.xfrom
Open
Pass through provider specific Gemini image aspect ratios#282morcken wants to merge 1 commit intolaravel:0.xfrom
morcken wants to merge 1 commit intolaravel:0.xfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gemini supports image aspect ratios such as
3:4, but the SDK currently drops any ratio outside1:1,2:3, and3:2when building Gemini image options.This PR makes Gemini consistent with the existing
size(string $size)API by passing through non-null size values asaspect_ratio, while preserving the existing mappings for1:1,2:3, and3:2.Reproduction
Before
GeminiProvider::defaultImageOptions()converted unknown aspect ratios tonull, sosize('3:4')was not forwarded to Gemini.After
sizevalues are passed through to Gemini asaspect_ratio.Why this change
3:4and other aspect ratios (https://ai.google.dev/gemini-api/docs/image-generation#3.1-flash-image-preview).size()already accepts a string at the public API level.Tests
Added a focused unit test that verifies:
3:4asaspect_ratio1:1) still behaves as beforeBackward Compatibility
This change is backward compatible:
square(),portrait(), andlandscape()are unchanged