Centralize prompt image detail modes (#42624)

## What changed

- Add `PromptImageMode::HIGH_DETAIL` and `PromptImageMode::ORIGINAL_DETAIL`
  constants with the standard resize limits.
- Use the shared modes during core image preparation instead of defining the
  limits locally.
- Cover the dimension and patch budgets for both detail modes in the image
  utility tests.

GitOrigin-RevId: 27fdc77719f23d2e8f1060886576b3be843a8491
This commit is contained in:
Krish Chainani authored and copyberry committed 2026-09-03 22:22:48 +00:00
1 parent 781c183c3b
commit 280ae8b9fc
3 files changed
+53 -38

No files matched your search

+13
View File
@@ -70,6 +70,19 @@ pub struct PromptImageResizeLimits {
pub max_patches: usize,
}
impl PromptImageMode {
/// Resize policy for high-detail prompt images.
pub const HIGH_DETAIL: Self = Self::ResizeWithLimits(PromptImageResizeLimits {
max_dimension: 2048,
max_patches: 2_500,
});
/// Resize policy for original-detail prompt images.
pub const ORIGINAL_DETAIL: Self = Self::ResizeWithLimits(PromptImageResizeLimits {
max_dimension: 6000,
max_patches: 10_000,
});
}
struct ImageMetadata {
icc_profile: Option<Vec<u8>>,
exif: Option<Vec<u8>>,