Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Adjust H3 Image resolution scale

Bitti0af909563ef2
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 5df359b..a49e46d 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -11,7 +11,7 @@ Changes since 0.4.0.
## Fixes and improvements
- Updated the bundled Slopfab runtime to 0.2.0, including a higher MiniMax H3 Image canvas limit of 20 MP.
-- MiniMax H3 Image resolution presets use four times the width and height. Switching image models keeps the same preset position; sizes above 20 MP are unavailable.
+- MiniMax H3 Image resolution presets scale width and height by 1.675, rounded down to the 32-pixel grid. The largest preset is 6080 × 3424, within the 20 MP limit. Switching image models keeps the same preset position.
- Fixed Extend rejecting editing drafts that already have a saved source image.
- YuE2 now defaults to six flow steps with DPM++ 2M. The previous Midpoint solver remains available in music's Advanced settings, and saved generator templates using the old 32-step default upgrade once to six steps.
- On first launch after updating, each recent project gets a one-time cleanup of orphaned generated media, latents and caches. Other projects receive the cleanup when first opened; files still referenced by the project are preserved.
diff --git a/src/components/workspace/ExtendSettings.tsx b/src/components/workspace/ExtendSettings.tsx
index b1e9d56..d6c174d 100644
--- a/src/components/workspace/ExtendSettings.tsx
+++ b/src/components/workspace/ExtendSettings.tsx
@@ -2,7 +2,7 @@ import { SliderNumberInput, GENERATION_STEPS_RANGE } from "./SliderNumberInput";
import { useMemo } from "react";
import { alignExtendBounds, compileExtendImage, initialExtendBounds, EXTEND_GRID, EXTEND_MAX_EDGE, type ExtendOptions } from "../../lib/extendImage";
import { PROJECT_RESOLUTIONS, type ProjectAsset, type ProjectConfig } from "../../lib/project";
-import { imageSettings, imageResolutionScale, imageGenerationDimensions, imageGenerationSizeError } from "../../lib/imageSettings";
+import { imageSettings, imageGenerationDimensions, imageGenerationSizeError } from "../../lib/imageSettings";
import { ComboBox, InfoBar, ItemHeader, PropRow } from "../ui";
import { Dismiss16, Sparkle16 } from "../ui/icons";
import { PromptTextField, type PromptReference } from "./PromptTextField";
@@ -29,8 +29,9 @@ export function ExtendSettings({ config, source, options, onChange, onResolution
<div className="image-inspector__fields image-template-settings__fields">
<PropRow label="Resolution" htmlFor="extend-resolution" tooltip="The box sets the aspect ratio. The selected resolution sets the pixel budget; expanding the box makes the source smaller within that output.">
<ComboBox id="extend-resolution" aria-label="Zoom resolution" value={imageSettings(config).resolution} options={PROJECT_RESOLUTIONS.map((value) => {
- const error = imageGenerationSizeError(imageGenerationDimensions(value, imageSettings(config).aspectRatio, template.modelType), template.modelType);
- return { value, label: `${Number.parseInt(value) * imageResolutionScale(template.modelType)}p`, disabled: Boolean(error), description: error ?? undefined };
+ const size = imageGenerationDimensions(value, imageSettings(config).aspectRatio, template.modelType);
+ const error = imageGenerationSizeError(size, template.modelType);
+ return { value, label: `${Math.min(size.width, size.height)}p`, disabled: Boolean(error), description: error ?? undefined };
})}
disabled={busy || !onResolutionChange} onChange={(value) => onResolutionChange?.(value)} />
</PropRow>
diff --git a/src/components/workspace/ImageEditor.test.tsx b/src/components/workspace/ImageEditor.test.tsx
index 8037b1b..5eab6e6 100644
--- a/src/components/workspace/ImageEditor.test.tsx
+++ b/src/components/workspace/ImageEditor.test.tsx
@@ -36,6 +36,7 @@ function setup(initial = parseProjectConfig(fixture), workItems: WorkItem[] = []
}
it("keeps the resolution preset when switching to H3 Image and back, including after reopening", () => {
+ vi.spyOn(persistence, "isTauri").mockReturnValue(true);
const normal = { ...defaultGeneratorTemplate(), id: "normal", name: "Normal image model" };
const h3 = { ...normal, id: "h3-image", name: "MiniMax H3 Image", modelType: "h3_image", defaultSteps: 6 };
saveGeneratorTemplateSettings({ templates: [normal, h3], defaultTemplateId: normal.id, catalogVersion: 23 });
@@ -46,8 +47,8 @@ it("keeps the resolution preset when switching to H3 Image and back, including a
const current = setup(initial);
expect(screen.getByRole("combobox", { name: "Resolution" })).toHaveTextContent("544 × 544");
choose("Generator", "MiniMax H3 Image");
- expect(screen.getByRole("combobox", { name: "Resolution" })).toHaveTextContent("2176 × 2176");
- choose("Resolution", "3072 × 3072");
+ expect(screen.getByRole("combobox", { name: "Resolution" })).toHaveTextContent("896 × 896");
+ choose("Resolution", "1280 × 1280");
expect(current().imageSettings?.resolution).toBe("768p");
choose("Generator", "Normal image model");
expect(screen.getByRole("combobox", { name: "Resolution" })).toHaveTextContent("768 × 768");
@@ -55,17 +56,16 @@ it("keeps the resolution preset when switching to H3 Image and back, including a
const saved = parseProjectConfig(current());
cleanup();
const reopened = setup(saved);
- expect(screen.getByRole("combobox", { name: "Resolution" })).toHaveTextContent("3072 × 3072");
+ expect(screen.getByRole("combobox", { name: "Resolution" })).toHaveTextContent("1280 × 1280");
fireEvent.click(screen.getByRole("combobox", { name: "Resolution" }));
- expect(screen.getByRole("option", { name: /8192 × 8192/ })).toHaveAttribute("aria-disabled", "true");
+ expect(screen.getByRole("option", { name: /3424 × 3424/ })).not.toHaveAttribute("aria-disabled", "true");
fireEvent.click(screen.getByRole("combobox", { name: "Resolution" }));
choose("Generator", "Normal image model");
choose("Resolution", "2048 × 2048");
choose("Generator", "MiniMax H3 Image");
- expect(screen.getByRole("combobox", { name: "Resolution" })).toHaveTextContent("8192 × 8192");
+ expect(screen.getByRole("combobox", { name: "Resolution" })).toHaveTextContent("3424 × 3424");
expect(reopened().imageSettings?.resolution).toBe("2048p");
- expect(screen.getByRole("button", { name: "Generate" })).toBeDisabled();
- expect(screen.getByRole("status")).toHaveTextContent("20 MP");
+ expect(screen.getByRole("button", { name: "Generate" })).toBeEnabled();
});
it("updates a low-resolution image preview in the canvas and image card, then removes it on completion", () => {
diff --git a/src/lib/h3Image.test.ts b/src/lib/h3Image.test.ts
index 9d4cd7e..5601e18 100644
--- a/src/lib/h3Image.test.ts
+++ b/src/lib/h3Image.test.ts
@@ -5,17 +5,30 @@ import { resolveH3Components } from "./h3Components";
import { compileImagePrompt } from "./imagePrompt";
import { compileExtendImage } from "./extendImage";
import { createImageEditScene } from "./imageScene";
-import { createProjectConfig } from "./project";
+import { createProjectConfig, PROJECT_RESOLUTIONS } from "./project";
+import { imageGenerationDimensions, imageGenerationSizeError } from "./imageSettings";
beforeEach(() => localStorage.clear());
const project = () => createProjectConfig({ name: "Image", generationType: "image", prompt: "A blue teapot", aspectRatio: "1:1", resolution: "416p", targetDurationSeconds: 15 });
-it("uses the same preset at four times each dimension for H3 Image Zoom", () => {
+it("keeps every H3 Image preset on the generation grid and within the pixel limit", () => {
+ expect(imageGenerationDimensions("2048p", "16:9", "h3_image")).toEqual({ width: 6080, height: 3424 });
+ for (const resolution of PROJECT_RESOLUTIONS) {
+ for (const aspectRatio of ["16:9", "9:16", "1:1", "4:5"] as const) {
+ const size = imageGenerationDimensions(resolution, aspectRatio, "h3_image");
+ expect(size.width % 32).toBe(0);
+ expect(size.height % 32).toBe(0);
+ expect(imageGenerationSizeError(size, "h3_image")).toBeNull();
+ }
+ }
+});
+
+it("uses the same preset scaled by 1.675 on the generation grid for H3 Image Zoom", () => {
const config = project();
const source = { id: "source", name: "Source", kind: "image" as const, mimeType: "image/png", width: 128, height: 128, createdAt: config.createdAt };
const options = { bounds: { x: -32, y: -32, width: 192, height: 192 }, prompt: "Forest", steps: 6, seed: 0 };
expect(compileExtendImage(config, source, "canvas.png", options, "minimax-h3").layout.output).toEqual({ width: 416, height: 416 });
- expect(compileExtendImage(config, source, "canvas.png", options, "h3_image").layout.output).toEqual({ width: 1664, height: 1664 });
+ expect(compileExtendImage(config, source, "canvas.png", options, "h3_image").layout.output).toEqual({ width: 672, height: 672 });
});
it("adds MiniMax H3 Image once without changing selected or custom generators, and respects removal", () => {
diff --git a/src/lib/imageSettings.ts b/src/lib/imageSettings.ts
index 4156cc3..b3b962b 100644
--- a/src/lib/imageSettings.ts
+++ b/src/lib/imageSettings.ts
@@ -5,13 +5,15 @@ export const H3_IMAGE_MAX_PIXELS = 20 * 1024 * 1024;
/** Keep the stored preset as a stable index across image models. */
export function imageResolutionScale(modelType?: string) {
- return modelType === "h3_image" ? 4 : 1;
+ return modelType === "h3_image" ? 1.675 : 1;
}
export function imageGenerationDimensions(resolution: Resolution, aspectRatio: AspectRatio, modelType?: string) {
const size = outputDimensions(resolution, aspectRatio);
const scale = imageResolutionScale(modelType);
- return { width: size.width * scale, height: size.height * scale };
+ if (scale === 1) return size;
+ // Round down to the generation grid to stay within the pixel budget.
+ return { width: Math.floor(size.width * scale / 32) * 32, height: Math.floor(size.height * scale / 32) * 32 };
}
export function imageGenerationSizeError(size: { width: number; height: number }, modelType?: string) {
diff --git a/src/lib/workQueue.test.ts b/src/lib/workQueue.test.ts
index f69c7e3..e428ba1 100644
--- a/src/lib/workQueue.test.ts
+++ b/src/lib/workQueue.test.ts
@@ -1045,17 +1045,17 @@ describe("agent scene generation", () => {
describe("image generation work", () => {
const template: GeneratorTemplate = { id: "image-test", name: "MiniMax H3", modelType: "minimax-h3", defaultSteps: 20, attention: "sage2", paths: { ...EMPTY_ENGINE_SETTINGS, transformer: "C:/h3.safetensors" } };
const imageProject = (): ProjectRecord => ({ folderPath: "C:/Image", config: createProjectConfig({ name: "Poster", prompt: "An ocean poster", generationType: "image", aspectRatio: "1:1", resolution: "768p", targetDurationSeconds: 60 }) });
- it("submits H3 Image at four times each dimension and rejects oversized presets before creating a draft", async () => {
+ it("submits H3 Image scaled by 1.675 on the generation grid and rejects oversized legacy presets before creating a draft", async () => {
const { queue } = setup();
const session = queue.project(imageProject());
const h3 = { ...template, modelType: "h3_image" };
const id = queue.enqueueImage(session, h3);
await waitFor(() => expect(enqueueSlopfabGeneration).toHaveBeenCalledOnce());
- expect(queue.getSnapshot().find(item => item.id === id)?.settings).toMatchObject({ canvasWidth: 3072, canvasHeight: 3072 });
- expect(vi.mocked(enqueueSlopfabGeneration).mock.calls[0][0]).toMatchObject({ canvasWidth: 3072, canvasHeight: 3072 });
+ expect(queue.getSnapshot().find(item => item.id === id)?.settings).toMatchObject({ canvasWidth: 1280, canvasHeight: 1280 });
+ expect(vi.mocked(enqueueSlopfabGeneration).mock.calls[0][0]).toMatchObject({ canvasWidth: 1280, canvasHeight: 1280 });
const oversized = imageProject();
oversized.folderPath = "C:/Oversized";
- oversized.config.imageSettings = { resolution: "1344p", aspectRatio: "1:1" };
+ oversized.config.imageSettings = { resolution: "4k", aspectRatio: "16:9" };
const other = queue.project(oversized);
const before = other.getSnapshot().config;
expect(() => queue.enqueueImage(other, h3)).toThrow("20 MP");