Browse Source

feat: add extended aspect ratios (1:4, 1:8, 4:1, 8:1) for Nano Banana 2

Make aspect ratio dropdowns model-aware: nano-banana-2 shows 14 ratios
while other models keep showing the base 10. Also add nano-banana-2 to
the SplitGrid settings model list.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 5 months ago
parent
commit
b71db648b2
  1. 9
      src/components/SplitGridSettingsModal.tsx
  2. 10
      src/components/nodes/GenerateImageNode.tsx
  3. 6
      src/types/models.ts

9
src/components/SplitGridSettingsModal.tsx

@ -20,10 +20,12 @@ const LAYOUT_OPTIONS = [
{ rows: 2, cols: 5 }, { rows: 2, cols: 5 },
] as const; ] as const;
const ASPECT_RATIOS: AspectRatio[] = ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"]; const BASE_ASPECT_RATIOS: AspectRatio[] = ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"];
const EXTENDED_ASPECT_RATIOS: AspectRatio[] = ["1:1", "1:4", "1:8", "2:3", "3:2", "3:4", "4:1", "4:3", "4:5", "5:4", "8:1", "9:16", "16:9", "21:9"];
const RESOLUTIONS: Resolution[] = ["1K", "2K", "4K"]; const RESOLUTIONS: Resolution[] = ["1K", "2K", "4K"];
const MODELS: { value: ModelType; label: string }[] = [ const MODELS: { value: ModelType; label: string }[] = [
{ value: "nano-banana", label: "Nano Banana" }, { value: "nano-banana", label: "Nano Banana" },
{ value: "nano-banana-2", label: "Nano Banana 2" },
{ value: "nano-banana-pro", label: "Nano Banana Pro" }, { value: "nano-banana-pro", label: "Nano Banana Pro" },
]; ];
@ -50,7 +52,8 @@ export function SplitGridSettingsModal({
const { rows, cols } = LAYOUT_OPTIONS[selectedLayoutIndex]; const { rows, cols } = LAYOUT_OPTIONS[selectedLayoutIndex];
const targetCount = rows * cols; const targetCount = rows * cols;
const isNanoBananaPro = model === "nano-banana-pro"; const isNanoBananaPro = model === "nano-banana-pro" || model === "nano-banana-2";
const aspectRatios = model === "nano-banana-2" ? EXTENDED_ASPECT_RATIOS : BASE_ASPECT_RATIOS;
const handleCreate = useCallback(() => { const handleCreate = useCallback(() => {
const splitNode = getNodeById(nodeId); const splitNode = getNodeById(nodeId);
@ -279,7 +282,7 @@ export function SplitGridSettingsModal({
onChange={(e) => setAspectRatio(e.target.value as AspectRatio)} onChange={(e) => setAspectRatio(e.target.value as AspectRatio)}
className="w-full px-3 py-2 bg-neutral-900 border border-neutral-600 rounded text-neutral-100 text-sm focus:outline-none focus:border-neutral-500" className="w-full px-3 py-2 bg-neutral-900 border border-neutral-600 rounded text-neutral-100 text-sm focus:outline-none focus:border-neutral-500"
> >
{ASPECT_RATIOS.map((ar) => ( {aspectRatios.map((ar) => (
<option key={ar} value={ar}>{ar}</option> <option key={ar} value={ar}>{ar}</option>
))} ))}
</select> </select>

10
src/components/nodes/GenerateImageNode.tsx

@ -14,8 +14,11 @@ import { useToast } from "@/components/Toast";
import { getImageDimensions, calculateNodeSizePreservingHeight } from "@/utils/nodeDimensions"; import { getImageDimensions, calculateNodeSizePreservingHeight } from "@/utils/nodeDimensions";
import { ProviderBadge } from "./ProviderBadge"; import { ProviderBadge } from "./ProviderBadge";
// All 10 aspect ratios supported by both models // Base 10 aspect ratios (all Gemini image models)
const ASPECT_RATIOS: AspectRatio[] = ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"]; const BASE_ASPECT_RATIOS: AspectRatio[] = ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"];
// Extended 14 aspect ratios (Nano Banana 2 adds extreme ratios)
const EXTENDED_ASPECT_RATIOS: AspectRatio[] = ["1:1", "1:4", "1:8", "2:3", "3:2", "3:4", "4:1", "4:3", "4:5", "5:4", "8:1", "9:16", "16:9", "21:9"];
// Resolutions for Nano Banana Pro and Nano Banana 2 // Resolutions for Nano Banana Pro and Nano Banana 2
const RESOLUTIONS: Resolution[] = ["512", "1K", "2K", "4K"]; const RESOLUTIONS: Resolution[] = ["512", "1K", "2K", "4K"];
@ -394,6 +397,7 @@ export function GenerateImageNode({ id, data, selected }: NodeProps<NanoBananaNo
// Use selectedModel.modelId for Gemini models, fallback to legacy model field // Use selectedModel.modelId for Gemini models, fallback to legacy model field
const currentModelId = isGeminiProvider ? (nodeData.selectedModel?.modelId || nodeData.model) : null; const currentModelId = isGeminiProvider ? (nodeData.selectedModel?.modelId || nodeData.model) : null;
const supportsResolution = currentModelId === "nano-banana-pro" || currentModelId === "nano-banana-2"; const supportsResolution = currentModelId === "nano-banana-pro" || currentModelId === "nano-banana-2";
const aspectRatios = currentModelId === "nano-banana-2" ? EXTENDED_ASPECT_RATIOS : BASE_ASPECT_RATIOS;
const hasCarouselImages = (nodeData.imageHistory || []).length > 1; const hasCarouselImages = (nodeData.imageHistory || []).length > 1;
// Track previous status to detect error transitions // Track previous status to detect error transitions
@ -689,7 +693,7 @@ export function GenerateImageNode({ id, data, selected }: NodeProps<NanoBananaNo
onChange={handleAspectRatioChange} onChange={handleAspectRatioChange}
className="flex-1 text-[10px] py-1 px-1.5 border border-neutral-700 rounded bg-neutral-900/50 focus:outline-none focus:ring-1 focus:ring-neutral-600 text-neutral-300" className="flex-1 text-[10px] py-1 px-1.5 border border-neutral-700 rounded bg-neutral-900/50 focus:outline-none focus:ring-1 focus:ring-neutral-600 text-neutral-300"
> >
{ASPECT_RATIOS.map((ratio) => ( {aspectRatios.map((ratio) => (
<option key={ratio} value={ratio}> <option key={ratio} value={ratio}>
{ratio} {ratio}
</option> </option>

6
src/types/models.ts

@ -5,15 +5,19 @@
* aspect ratios, resolutions, and model identifiers. * aspect ratios, resolutions, and model identifiers.
*/ */
// Aspect Ratios (supported by both Nano Banana and Nano Banana Pro) // Aspect Ratios (all models support the base 10; Nano Banana 2 adds 1:4, 1:8, 4:1, 8:1)
export type AspectRatio = export type AspectRatio =
| "1:1" | "1:1"
| "1:4"
| "1:8"
| "2:3" | "2:3"
| "3:2" | "3:2"
| "3:4" | "3:4"
| "4:1"
| "4:3" | "4:3"
| "4:5" | "4:5"
| "5:4" | "5:4"
| "8:1"
| "9:16" | "9:16"
| "16:9" | "16:9"
| "21:9"; | "21:9";

Loading…
Cancel
Save