Skip to content

fix(image): preserve resolution with enum validation when changing aspect ratio#13935

Open
Mati0kez wants to merge 2 commits intolobehub:canaryfrom
Mati0kez:canary
Open

fix(image): preserve resolution with enum validation when changing aspect ratio#13935
Mati0kez wants to merge 2 commits intolobehub:canaryfrom
Mati0kez:canary

Conversation

@Mati0kez
Copy link
Copy Markdown

Summary

When using models that support resolution enum (1K/2K/4K), selecting a different aspect ratio would cause the resolution to be lost. This PR fixes the issue by:

  1. Preserving resolution when changing aspect ratios for models that support the same resolution enum value
  2. Stripping resolution when the new aspect ratio's schema doesn't support the current resolution value

Fixes #13283

Changes

Code Fix (action.ts)

Added validation logic to setAspectRatio that:

  • Preserves parameters.resolution if the new schema's enum includes the current value
  • Strips parameters.resolution if the new schema's enum doesn't include the value, or if the schema has no resolution enum

Tests (action.test.ts)

Added 3 regression tests under Aspect Ratio Setting describe block:

  • should preserve resolution when changing aspect ratio for models with resolution enum
  • should strip resolution when new schema does not support the current resolution value
  • should strip resolution when schema has no resolution enum

Reviewer Feedback Addressed

This PR supersedes #13324 by addressing:

  1. ✅ Adding regression test for resolution preservation
  2. ✅ Validating preserved value against schema's enum

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 17, 2026

@Mati0kez is attempting to deploy a commit to the LobeHub OSS Team on Vercel.

A member of the Team first needs to authorize it.

@Mati0kez
Copy link
Copy Markdown
Author

This PR supersedes #13324 and addresses both review comments from @tjx666:

  1. Added regression tests for resolution preservation behavior
  2. Added enum validation to strip resolution when not valid for new schema

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@lobehubbot
Copy link
Copy Markdown
Member

@tjx666 - This is an image generation fix (resolution preservation when changing aspect ratio). Please take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect Resolution Size in Image Generation

2 participants