From e93c8b728f91995342c21caa185cc5f9516ed2e4 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Thu, 26 Mar 2026 16:00:12 -0400 Subject: [PATCH] Add more resolution options --- .../src/api/common_resolution.rs | 12 ++++++ ...n_generate_image_artcraft_nano_banana_2.rs | 2 + ...generate_image_artcraft_nano_banana_pro.rs | 2 + ...plan_generate_image_fal_nano_banana_pro.rs | 5 +++ ...generate_video_artcraft_seedance1p5_pro.rs | 4 ++ .../resolution/common_resolution.rs | 12 ++++++ .../resolution_to_artcraft_nano_banana_pro.rs | 5 +++ ...andle_text_to_image_artcraft_via_router.rs | 4 ++ .../common/generation/common_resolution.rs | 42 ++++++++++++++++++- .../image/estimate_image_cost_handler.rs | 4 ++ .../video/estimate_video_cost_handler.rs | 4 ++ 11 files changed, 94 insertions(+), 2 deletions(-) diff --git a/crates/api_clients/artcraft/artcraft_router/src/api/common_resolution.rs b/crates/api_clients/artcraft/artcraft_router/src/api/common_resolution.rs index 6a77bbcd60..77e09ce11c 100644 --- a/crates/api_clients/artcraft/artcraft_router/src/api/common_resolution.rs +++ b/crates/api_clients/artcraft/artcraft_router/src/api/common_resolution.rs @@ -14,4 +14,16 @@ pub enum CommonResolution { ThreeK, /// Models: Nano Banana Pro FourK, + + /// Used by Nano Banana 2 (and others) + HalfK, + + /// Used by the Seedance family (and others) + FourEightyP, + + /// Used by the Seedance family (and others) + SevenTwentyP, + + /// Used by the Seedance family (and others) + TenEightyP, } diff --git a/crates/api_clients/artcraft/artcraft_router/src/generate/generate_image/plan/artcraft/plan_generate_image_artcraft_nano_banana_2.rs b/crates/api_clients/artcraft/artcraft_router/src/generate/generate_image/plan/artcraft/plan_generate_image_artcraft_nano_banana_2.rs index cf76b27ae7..973474678e 100644 --- a/crates/api_clients/artcraft/artcraft_router/src/generate/generate_image/plan/artcraft/plan_generate_image_artcraft_nano_banana_2.rs +++ b/crates/api_clients/artcraft/artcraft_router/src/generate/generate_image/plan/artcraft/plan_generate_image_artcraft_nano_banana_2.rs @@ -135,6 +135,8 @@ fn plan_resolution( // No 3K option; default to 2K Ok(Some(Nb2Res::TwoK)) } + // HalfK, FourEightyP, SevenTwentyP, TenEightyP — nearest supported is OneK + Some(R::HalfK | R::FourEightyP | R::SevenTwentyP | R::TenEightyP) => Ok(Some(Nb2Res::OneK)), } } diff --git a/crates/api_clients/artcraft/artcraft_router/src/generate/generate_image/plan/artcraft/plan_generate_image_artcraft_nano_banana_pro.rs b/crates/api_clients/artcraft/artcraft_router/src/generate/generate_image/plan/artcraft/plan_generate_image_artcraft_nano_banana_pro.rs index 0832308467..827e409946 100644 --- a/crates/api_clients/artcraft/artcraft_router/src/generate/generate_image/plan/artcraft/plan_generate_image_artcraft_nano_banana_pro.rs +++ b/crates/api_clients/artcraft/artcraft_router/src/generate/generate_image/plan/artcraft/plan_generate_image_artcraft_nano_banana_pro.rs @@ -135,6 +135,8 @@ fn plan_resolution( // No 3K option; default to 2K Ok(Some(NbpRes::TwoK)) } + // HalfK, FourEightyP, SevenTwentyP, TenEightyP — nearest supported is OneK + Some(R::HalfK | R::FourEightyP | R::SevenTwentyP | R::TenEightyP) => Ok(Some(NbpRes::OneK)), } } diff --git a/crates/api_clients/artcraft/artcraft_router/src/generate/generate_image/plan/fal/plan_generate_image_fal_nano_banana_pro.rs b/crates/api_clients/artcraft/artcraft_router/src/generate/generate_image/plan/fal/plan_generate_image_fal_nano_banana_pro.rs index a027ef0c6e..9e7a82d612 100644 --- a/crates/api_clients/artcraft/artcraft_router/src/generate/generate_image/plan/fal/plan_generate_image_fal_nano_banana_pro.rs +++ b/crates/api_clients/artcraft/artcraft_router/src/generate/generate_image/plan/fal/plan_generate_image_fal_nano_banana_pro.rs @@ -202,6 +202,11 @@ fn plan_resolution( Some(CommonResolution::FourK) => Ok(Some(FalNbpResolution::FourK)), // No 3K option; fall back to 2K Some(CommonResolution::ThreeK) => Ok(Some(FalNbpResolution::TwoK)), + // Fall back to nearest supported resolution + Some(CommonResolution::HalfK) => Ok(Some(FalNbpResolution::OneK)), + Some(CommonResolution::FourEightyP) => Ok(Some(FalNbpResolution::OneK)), + Some(CommonResolution::SevenTwentyP) => Ok(Some(FalNbpResolution::OneK)), + Some(CommonResolution::TenEightyP) => Ok(Some(FalNbpResolution::OneK)), } } diff --git a/crates/api_clients/artcraft/artcraft_router/src/generate/generate_video/plan/artcraft/plan_generate_video_artcraft_seedance1p5_pro.rs b/crates/api_clients/artcraft/artcraft_router/src/generate/generate_video/plan/artcraft/plan_generate_video_artcraft_seedance1p5_pro.rs index de0f134afe..648e790b7c 100644 --- a/crates/api_clients/artcraft/artcraft_router/src/generate/generate_video/plan/artcraft/plan_generate_video_artcraft_seedance1p5_pro.rs +++ b/crates/api_clients/artcraft/artcraft_router/src/generate/generate_video/plan/artcraft/plan_generate_video_artcraft_seedance1p5_pro.rs @@ -167,6 +167,10 @@ fn plan_resolution( Some(CommonResolution::TwoK) => Ok(Some(Seedance1p5ProMultiFunctionVideoGenResolution::TenEightyP)), Some(CommonResolution::ThreeK) => Ok(Some(Seedance1p5ProMultiFunctionVideoGenResolution::TenEightyP)), Some(CommonResolution::FourK) => Ok(Some(Seedance1p5ProMultiFunctionVideoGenResolution::TenEightyP)), + // HalfK and FourEightyP map to the lowest supported resolution + Some(CommonResolution::HalfK | CommonResolution::FourEightyP) => Ok(Some(Seedance1p5ProMultiFunctionVideoGenResolution::FourEightyP)), + Some(CommonResolution::SevenTwentyP) => Ok(Some(Seedance1p5ProMultiFunctionVideoGenResolution::SevenTwentyP)), + Some(CommonResolution::TenEightyP) => Ok(Some(Seedance1p5ProMultiFunctionVideoGenResolution::TenEightyP)), } } diff --git a/crates/desktop/artcraft/src/core/api_adapters/resolution/common_resolution.rs b/crates/desktop/artcraft/src/core/api_adapters/resolution/common_resolution.rs index f262faadb8..3b401c02e4 100644 --- a/crates/desktop/artcraft/src/core/api_adapters/resolution/common_resolution.rs +++ b/crates/desktop/artcraft/src/core/api_adapters/resolution/common_resolution.rs @@ -14,4 +14,16 @@ pub enum CommonResolution { ThreeK, /// Models: Nano Banana Pro FourK, + + /// Used by Nano Banana 2 (and others) + HalfK, + + /// Used by the Seedance family (and others) + FourEightyP, + + /// Used by the Seedance family (and others) + SevenTwentyP, + + /// Used by the Seedance family (and others) + TenEightyP, } diff --git a/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/resolution_to_artcraft_nano_banana_pro.rs b/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/resolution_to_artcraft_nano_banana_pro.rs index a7668aed7a..a880943bcc 100644 --- a/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/resolution_to_artcraft_nano_banana_pro.rs +++ b/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/resolution_to_artcraft_nano_banana_pro.rs @@ -8,5 +8,10 @@ pub fn resolution_to_artcraft_nano_banana_pro(resolution: CommonResolution) -> N // NB: ThreeK doesn't exist in Nano Banana Pro, use FourK as nearest higher resolution CommonResolution::ThreeK => NanoBananaProMultiFunctionImageGenImageResolution::FourK, CommonResolution::FourK => NanoBananaProMultiFunctionImageGenImageResolution::FourK, + // Fall back to nearest supported resolution + CommonResolution::HalfK => NanoBananaProMultiFunctionImageGenImageResolution::OneK, + CommonResolution::FourEightyP => NanoBananaProMultiFunctionImageGenImageResolution::OneK, + CommonResolution::SevenTwentyP => NanoBananaProMultiFunctionImageGenImageResolution::OneK, + CommonResolution::TenEightyP => NanoBananaProMultiFunctionImageGenImageResolution::OneK, } } diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/text_to_image/artcraft/handle_text_to_image_artcraft_via_router.rs b/crates/desktop/artcraft/src/core/commands/enqueue/text_to_image/artcraft/handle_text_to_image_artcraft_via_router.rs index 0a375585d1..7a19c172dc 100644 --- a/crates/desktop/artcraft/src/core/commands/enqueue/text_to_image/artcraft/handle_text_to_image_artcraft_via_router.rs +++ b/crates/desktop/artcraft/src/core/commands/enqueue/text_to_image/artcraft/handle_text_to_image_artcraft_via_router.rs @@ -144,5 +144,9 @@ fn convert_desktop_resolution(res: CommonResolution2) -> RouterCommonResolution CommonResolution2::TwoK => RouterCommonResolution::TwoK, CommonResolution2::ThreeK => RouterCommonResolution::ThreeK, CommonResolution2::FourK => RouterCommonResolution::FourK, + CommonResolution2::HalfK => RouterCommonResolution::HalfK, + CommonResolution2::FourEightyP => RouterCommonResolution::FourEightyP, + CommonResolution2::SevenTwentyP => RouterCommonResolution::SevenTwentyP, + CommonResolution2::TenEightyP => RouterCommonResolution::TenEightyP, } } diff --git a/crates/schema/public/enums/src/common/generation/common_resolution.rs b/crates/schema/public/enums/src/common/generation/common_resolution.rs index 7c8c07e8c0..6c4eaf6d5c 100644 --- a/crates/schema/public/enums/src/common/generation/common_resolution.rs +++ b/crates/schema/public/enums/src/common/generation/common_resolution.rs @@ -23,7 +23,17 @@ pub enum CommonResolution { ThreeK, FourK, - // TODO: Add 480p(?), 720p(?), 1080p, etc. as there are some models that use these + /// Used by Nano Banana 2 (and others) + HalfK, + + /// Used by the Seedance family (and others) + FourEightyP, + + /// Used by the Seedance family (and others) + SevenTwentyP, + + /// Used by the Seedance family (and others) + TenEightyP, } impl_enum_display_and_debug_using_to_str!(CommonResolution); @@ -37,6 +47,10 @@ impl CommonResolution { Self::TwoK => "two_k", Self::ThreeK => "three_k", Self::FourK => "four_k", + Self::HalfK => "half_k", + Self::FourEightyP => "four_eighty_p", + Self::SevenTwentyP => "seven_twenty_p", + Self::TenEightyP => "ten_eighty_p", } } @@ -46,6 +60,10 @@ impl CommonResolution { "two_k" => Ok(Self::TwoK), "three_k" => Ok(Self::ThreeK), "four_k" => Ok(Self::FourK), + "half_k" => Ok(Self::HalfK), + "four_eighty_p" => Ok(Self::FourEightyP), + "seven_twenty_p" => Ok(Self::SevenTwentyP), + "ten_eighty_p" => Ok(Self::TenEightyP), _ => Err(EnumError::CouldNotConvertFromString(value.to_string())), } } @@ -56,6 +74,10 @@ impl CommonResolution { Self::TwoK, Self::ThreeK, Self::FourK, + Self::HalfK, + Self::FourEightyP, + Self::SevenTwentyP, + Self::TenEightyP, ]) } } @@ -76,6 +98,10 @@ mod tests { assert_serialization(CommonResolution::TwoK, "two_k"); assert_serialization(CommonResolution::ThreeK, "three_k"); assert_serialization(CommonResolution::FourK, "four_k"); + assert_serialization(CommonResolution::HalfK, "half_k"); + assert_serialization(CommonResolution::FourEightyP, "four_eighty_p"); + assert_serialization(CommonResolution::SevenTwentyP, "seven_twenty_p"); + assert_serialization(CommonResolution::TenEightyP, "ten_eighty_p"); } #[test] @@ -84,6 +110,10 @@ mod tests { assert_eq!(CommonResolution::TwoK.to_str(), "two_k"); assert_eq!(CommonResolution::ThreeK.to_str(), "three_k"); assert_eq!(CommonResolution::FourK.to_str(), "four_k"); + assert_eq!(CommonResolution::HalfK.to_str(), "half_k"); + assert_eq!(CommonResolution::FourEightyP.to_str(), "four_eighty_p"); + assert_eq!(CommonResolution::SevenTwentyP.to_str(), "seven_twenty_p"); + assert_eq!(CommonResolution::TenEightyP.to_str(), "ten_eighty_p"); } #[test] @@ -92,6 +122,10 @@ mod tests { assert_eq!(CommonResolution::from_str("two_k").unwrap(), CommonResolution::TwoK); assert_eq!(CommonResolution::from_str("three_k").unwrap(), CommonResolution::ThreeK); assert_eq!(CommonResolution::from_str("four_k").unwrap(), CommonResolution::FourK); + assert_eq!(CommonResolution::from_str("half_k").unwrap(), CommonResolution::HalfK); + assert_eq!(CommonResolution::from_str("four_eighty_p").unwrap(), CommonResolution::FourEightyP); + assert_eq!(CommonResolution::from_str("seven_twenty_p").unwrap(), CommonResolution::SevenTwentyP); + assert_eq!(CommonResolution::from_str("ten_eighty_p").unwrap(), CommonResolution::TenEightyP); } #[test] @@ -108,11 +142,15 @@ mod tests { #[test] fn all_variants() { let mut variants = CommonResolution::all_variants(); - assert_eq!(variants.len(), 4); + assert_eq!(variants.len(), 8); assert_eq!(variants.pop_first(), Some(CommonResolution::OneK)); assert_eq!(variants.pop_first(), Some(CommonResolution::TwoK)); assert_eq!(variants.pop_first(), Some(CommonResolution::ThreeK)); assert_eq!(variants.pop_first(), Some(CommonResolution::FourK)); + assert_eq!(variants.pop_first(), Some(CommonResolution::HalfK)); + assert_eq!(variants.pop_first(), Some(CommonResolution::FourEightyP)); + assert_eq!(variants.pop_first(), Some(CommonResolution::SevenTwentyP)); + assert_eq!(variants.pop_first(), Some(CommonResolution::TenEightyP)); assert_eq!(variants.pop_first(), None); } } diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/generate/cost_estimate/image/estimate_image_cost_handler.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/generate/cost_estimate/image/estimate_image_cost_handler.rs index 040b41377d..1a8d058474 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/generate/cost_estimate/image/estimate_image_cost_handler.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/generate/cost_estimate/image/estimate_image_cost_handler.rs @@ -168,5 +168,9 @@ fn map_resolution(res: CommonResolution) -> RouterResolution { CommonResolution::TwoK => RouterResolution::TwoK, CommonResolution::ThreeK => RouterResolution::ThreeK, CommonResolution::FourK => RouterResolution::FourK, + CommonResolution::HalfK => RouterResolution::HalfK, + CommonResolution::FourEightyP => RouterResolution::FourEightyP, + CommonResolution::SevenTwentyP => RouterResolution::SevenTwentyP, + CommonResolution::TenEightyP => RouterResolution::TenEightyP, } } diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/generate/cost_estimate/video/estimate_video_cost_handler.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/generate/cost_estimate/video/estimate_video_cost_handler.rs index bf5c85f2e1..1aafbfdd70 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/generate/cost_estimate/video/estimate_video_cost_handler.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/generate/cost_estimate/video/estimate_video_cost_handler.rs @@ -178,5 +178,9 @@ fn map_resolution(res: CommonResolution) -> RouterResolution { CommonResolution::TwoK => RouterResolution::TwoK, CommonResolution::ThreeK => RouterResolution::ThreeK, CommonResolution::FourK => RouterResolution::FourK, + CommonResolution::HalfK => RouterResolution::HalfK, + CommonResolution::FourEightyP => RouterResolution::FourEightyP, + CommonResolution::SevenTwentyP => RouterResolution::SevenTwentyP, + CommonResolution::TenEightyP => RouterResolution::TenEightyP, } }