Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Separate image and video generation settings

Bitti478349e9ab84
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index ad968d9..9cc936c 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -32,6 +32,7 @@ This alpha update adds LAN generation workers, Linux support, expanded color gra
## Fixes and improvements
+- Still-image resolution and aspect ratio are saved separately from video project settings. Editing or selecting an image no longer changes the canvas used for video generation and continuation.
- Zoom the timeline video preview up to 400% with the zoom menu, buttons, or Ctrl+wheel, and scroll to inspect details. Choose Fit to see the whole frame again.
- Video scenes offer a separate audio step count. Audio follows the video step count by default, with optional overrides for local and worker generation.
- Character Sheet lets you enable Close up, Front view, Side view and Back view independently. Side view is off by default; generation and the combined image include only enabled views.
diff --git a/src-tauri/src/project/model.rs b/src-tauri/src/project/model.rs
index 7a32158..4335f61 100644
--- a/src-tauri/src/project/model.rs
+++ b/src-tauri/src/project/model.rs
@@ -23,6 +23,8 @@ pub(crate) struct ProjectConfig {
pub(crate) generation_type: GenerationType,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) image_scene: Option<super::image::ImageScene>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) image_settings: Option<ImageSettings>,
pub(crate) id: String,
pub(crate) name: String,
pub(crate) created_at: String,
@@ -44,6 +46,15 @@ pub(crate) struct ProjectConfig {
pub(crate) provider_settings: BTreeMap<String, ProviderSetting>,
}
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub(crate) struct ImageSettings {
+ pub(crate) resolution: String,
+ pub(crate) aspect_ratio: String,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) default_look: Option<String>,
+}
+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ProjectSettings {
diff --git a/src-tauri/src/project/validation/settings.rs b/src-tauri/src/project/validation/settings.rs
index 49f3217..b7c16b5 100644
--- a/src-tauri/src/project/validation/settings.rs
+++ b/src-tauri/src/project/validation/settings.rs
@@ -21,6 +21,14 @@ pub(super) fn validate(config: &mut ProjectConfig) -> Result<(), String> {
}
check_iso_datetime("Project createdAt", &config.created_at)?;
check_iso_datetime("Project updatedAt", &config.updated_at)?;
+ if let Some(settings) = &config.image_settings {
+ if !is_supported_resolution(&settings.resolution)
+ || !is_supported_aspect_ratio(&settings.aspect_ratio)
+ || settings.default_look.as_ref().is_some_and(|look| !is_shot_tag_id(look))
+ {
+ return Err("Invalid still-image generation settings.".into());
+ }
+ }
if !is_supported_aspect_ratio(&config.settings.aspect_ratio) {
return Err(format!(
"Unsupported aspect ratio '{}'.",
diff --git a/src-tauri/src/tests/images.rs b/src-tauri/src/tests/images.rs
index 941356c..4d9ae7c 100644
--- a/src-tauri/src/tests/images.rs
+++ b/src-tauri/src/tests/images.rs
@@ -146,6 +146,23 @@ fn image_export_resizes_and_reencodes_at_the_chosen_quality() {
assert!(export_image_file_with(&source, &zero, ImageExportOptions { format: None, width: Some(0), height: Some(40), quality: None, ..Default::default() }).is_err());
}
+#[test]
+fn image_settings_survive_save_without_changing_video_settings() {
+ let mut config = image_fixture();
+ config.image_settings = Some(serde_json::from_value(serde_json::json!({
+ "resolution": "1536p", "aspectRatio": "1:1", "defaultLook": "watercolor"
+ })).unwrap());
+ let root = tempfile::tempdir().unwrap();
+ let created = create_project_in(root.path(), &config).unwrap();
+ let opened = read_project(Path::new(&created.folder_path)).unwrap();
+ assert_eq!(opened.config.image_settings, config.image_settings);
+ assert_eq!(opened.config.settings, config.settings);
+ assert_eq!(opened.config.brief, config.brief);
+ let mut invalid = opened.config;
+ invalid.image_settings.as_mut().unwrap().resolution = "invalid".into();
+ assert!(validate_and_normalize_config(invalid).is_err());
+}
+
#[test]
fn image_export_does_not_silently_skip_a_selected_upscaler() {
use crate::commands::artifacts::{export_image_file_with, ImageExportOptions};
diff --git a/src/components/workspace/CharacterSheetSettings.tsx b/src/components/workspace/CharacterSheetSettings.tsx
index e66c4ec..6292448 100644
--- a/src/components/workspace/CharacterSheetSettings.tsx
+++ b/src/components/workspace/CharacterSheetSettings.tsx
@@ -1,3 +1,4 @@
+import { imageSettings } from "../../lib/imageSettings";
import { useMemo, useState } from "react";
import { CHARACTER_SHEET_HEIGHTS, CHARACTER_SHEET_ORDER, CHARACTER_SHEET_VIEWS, characterSheetDimensions, characterSheetViewIndices, characterSheetViews, compileCharacterSheet, emptyCharacterSheetOptions, type CharacterSheetOptions } from "../../lib/characterSheet";
import type { ProjectAsset, ProjectConfig } from "../../lib/project";
@@ -12,11 +13,11 @@ export function CharacterSheetSettings({ config, source, references, missingLabe
initialOptions?: CharacterSheetOptions;
onExecute: (options: CharacterSheetOptions) => void; onClose: () => void;
}) {
- const [options, setOptions] = useState<CharacterSheetOptions>(() => ({ ...emptyCharacterSheetOptions(), height: characterSheetDimensions(config.settings.resolution)[0].height,
+ const [options, setOptions] = useState<CharacterSheetOptions>(() => ({ ...emptyCharacterSheetOptions(), height: characterSheetDimensions(imageSettings(config).resolution)[0].height,
steps: config.imageScene?.steps ?? defaultSteps, seed: config.imageScene?.seed ?? -1, ...initialOptions,
// Older submitted sheets always generated all four views.
...(initialOptions && !initialOptions.views ? { views: { closeUp: true, front: true, side: true, back: true } } : {}) }));
- const dimensions = characterSheetDimensions(config.settings.resolution, options.height);
+ const dimensions = characterSheetDimensions(imageSettings(config).resolution, options.height);
const selectedViews = characterSheetViews(options);
const indices = characterSheetViewIndices(options);
const [error, setError] = useState<string | null>(null);
diff --git a/src/components/workspace/ImageEditor.test.tsx b/src/components/workspace/ImageEditor.test.tsx
index 324aabd..3972fdd 100644
--- a/src/components/workspace/ImageEditor.test.tsx
+++ b/src/components/workspace/ImageEditor.test.tsx
@@ -407,7 +407,7 @@ it("restores the hierarchy, prompts, settings and generator when selecting a sav
expect(screen.getByRole("button", { name: "Lantern" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Lettering" })).toBeInTheDocument();
expect(current().references).toEqual(saved.references);
- expect(current().settings).toMatchObject({ resolution: "1088p", aspectRatio: "4:5" });
+ expect(current().imageSettings).toMatchObject({ resolution: "1088p", aspectRatio: "4:5" });
// Viewing a result starts a fresh history: Ctrl+Z has nothing to undo.
undoImageEdit();
expect(promptValue(screen.getByLabelText("Prompt (high-level description)"))).toBe(saved.scene.nodes[0].description);
@@ -418,6 +418,9 @@ it("restores the hierarchy, prompts, settings and generator when selecting a sav
fireEvent.click(screen.getByRole("button", { name: "View Result 1" }));
expect(current().imageScene).toEqual({ ...saved.scene, outputAssetId: "result-1" });
expect(current().assets[1].imageGeneration).toEqual(saved);
+ expect(current().settings).toEqual(initial.settings);
+ expect(current().brief.resolution).toBe(initial.brief.resolution);
+ expect(current().brief.aspectRatio).toBe(initial.brief.aspectRatio);
});
it("displays each generated image at its saved aspect ratio independently of future generation settings", () => {
@@ -431,10 +434,12 @@ it("displays each generated image at its saved aspect ratio independently of fut
const frame = screen.getByLabelText("Image placement canvas").parentElement!;
expect(frame.style.getPropertyValue("--image-ratio")).toBe(String(1376 / 768));
choose("Resolution", "2720 × 1536");
- expect(current().settings.resolution).toBe("1536p");
+ expect(current().imageSettings?.resolution).toBe("1536p");
+ expect(current().settings).toEqual(initial.settings);
+ expect(current().brief).toEqual(initial.brief);
choose("Resolution", "3648 × 2048");
choose("Aspect ratio", "1:1");
- expect(current().settings).toMatchObject({ resolution: "2048p", aspectRatio: "1:1" });
+ expect(current().imageSettings).toMatchObject({ resolution: "2048p", aspectRatio: "1:1" });
expect(frame.style.getPropertyValue("--image-ratio")).toBe(String(1376 / 768));
fireEvent.click(screen.getByRole("button", { name: "View Tall" }));
expect(frame.style.getPropertyValue("--image-ratio")).toBe(String(1088 / 1920));
@@ -442,7 +447,9 @@ it("displays each generated image at its saved aspect ratio independently of fut
expect(frame.style.getPropertyValue("--image-ratio")).toBe(String(1376 / 768));
const reopened = parseProjectConfig(JSON.parse(JSON.stringify(current())));
expect(reopened.assets).toEqual(initial.assets);
- expect(reopened.settings).toMatchObject({ resolution: "2048p", aspectRatio: "1:1" });
+ expect(reopened.settings).toEqual(initial.settings);
+ expect(reopened.brief).toEqual(initial.brief);
+ expect(reopened.imageSettings).toMatchObject({ resolution: "2048p", aspectRatio: "1:1" });
});
it("removes generated images through their context menu and keeps the preview and thumbnail valid", () => {
diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsx
index ee8f36e..93ea837 100644
--- a/src/components/workspace/ImageEditor.tsx
+++ b/src/components/workspace/ImageEditor.tsx
@@ -3,6 +3,7 @@ import { Add14, Add16, Boxes16, Boxes16Filled, ChevronDown14, ChevronRight14, Co
import { invoke } from "@tauri-apps/api/core";
import { addImageNode, createImageEditScene, createImageScene, duplicateImageNode, imageDescendants, imageScenePrompt, removeImageNode, resizeImageNode, type ImageBox, type ImageNode, type ImageScene, type ImageSource } from "../../lib/imageScene";
import { compileImageEdits, editGeneratedImage, imageEditDebugPrompt } from "../../lib/imageEditing";
+import { imageSettings } from "../../lib/imageSettings";
import { outputDimensions } from "../../lib/export";
import { compileImagePrompt } from "../../lib/imagePrompt";
import { createEmptyImage, imageFamily, imageFamilyRoot, makeImagePrimary, removeImageAsset, restoreGeneratedImage, saveImageDraft } from "../../lib/imageHistory";
@@ -55,6 +56,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
onImageOpened?: () => void;
}) {
const scene = useMemo(() => config.imageScene ?? createImageScene(config.brief.prompt), [config.imageScene, config.brief.prompt]);
+ const settings = imageSettings(config);
const root = scene.nodes.find((node) => node.kind === "root")!;
const imageRoot = scene.rootType === "image";
const generatedImage = config.assets.find((asset) => asset.id === scene.outputAssetId && !asset.imageDraft && asset.imageGeneration);
@@ -165,10 +167,10 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
const menuImage = images.find((asset) => asset.id === imageMenu?.id);
const canUseMenuImage = Boolean(menuImage?.relativePath || menuImage?.sourcePath);
// Generated assets retain the dimensions returned by the native encoder.
- // Project settings size only the empty canvas and future generation requests.
+ // Image settings size only the empty canvas and future generation requests.
const { width, height } = imageRoot && scene.sourceImage ? scene.sourceImage : output?.width && output?.height
? { width: output.width, height: output.height }
- : outputDimensions(config.settings.resolution, config.settings.aspectRatio);
+ : outputDimensions(settings.resolution, settings.aspectRatio);
useEffect(() => subscribeGeneratorTemplates(() => setTemplates(loadGeneratorTemplateSettings())), []);
const commit = (next: ImageScene) => {
@@ -719,8 +721,8 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
<PropRow label="Steps" htmlFor={rootField("steps")}><input id={rootField("steps")} className="text-field" type="number" min="2" max="1000" value={scene.steps} onChange={(event) => { const value = Number(event.target.value); if (Number.isInteger(value) && value >= 2 && value <= 1000) commit({ ...scene, steps: value }); }} /></PropRow>
<PropRow label="Seed" htmlFor={rootField("seed")}><input id={rootField("seed")} className="text-field" type="number" min="-1" max={Number.MAX_SAFE_INTEGER} value={scene.seed} data-tooltip="-1 picks a random seed" onChange={(event) => { const value = Number(event.target.value); if (Number.isSafeInteger(value) && value >= -1) commit({ ...scene, seed: value }); }} /></PropRow>
{generatedImage && <UsedImageSeed id={rootField("used-seed")} seed={usedSeed} onError={setError} />}
- <PropRow label="Aspect ratio" htmlFor={rootField("ratio")}><ComboBox id={rootField("ratio")} aria-label="Aspect ratio" value={config.settings.aspectRatio} options={["16:9", "9:16", "1:1", "4:5"].map((ratio) => ({ value: ratio, label: ratio }))} onChange={(value) => { const aspectRatio = value as ProjectConfig["settings"]["aspectRatio"]; onChange((current) => ({ ...current, settings: { ...current.settings, aspectRatio }, brief: { ...current.brief, aspectRatio } })); }} /></PropRow>
- <PropRow label="Resolution" htmlFor={rootField("resolution")}><ComboBox id={rootField("resolution")} aria-label="Resolution" value={config.settings.resolution} options={[...new Set([...PROJECT_RESOLUTIONS, config.settings.resolution])].map((resolution) => { const size = outputDimensions(resolution, config.settings.aspectRatio); return { value: resolution, label: `${size.width} × ${size.height}` }; })} onChange={(value) => { const resolution = value as ProjectConfig["settings"]["resolution"]; onChange((current) => ({ ...current, settings: { ...current.settings, resolution }, brief: { ...current.brief, resolution } })); }} /></PropRow>
+ <PropRow label="Aspect ratio" htmlFor={rootField("ratio")}><ComboBox id={rootField("ratio")} aria-label="Aspect ratio" value={settings.aspectRatio} options={["16:9", "9:16", "1:1", "4:5"].map((ratio) => ({ value: ratio, label: ratio }))} onChange={(value) => { const aspectRatio = value as ProjectConfig["settings"]["aspectRatio"]; onChange((current) => ({ ...current, imageSettings: { ...imageSettings(current), aspectRatio } })); }} /></PropRow>
+ <PropRow label="Resolution" htmlFor={rootField("resolution")}><ComboBox id={rootField("resolution")} aria-label="Resolution" value={settings.resolution} options={[...new Set([...PROJECT_RESOLUTIONS, settings.resolution])].map((resolution) => { const size = outputDimensions(resolution, settings.aspectRatio); return { value: resolution, label: `${size.width} × ${size.height}` }; })} onChange={(value) => { const resolution = value as ProjectConfig["settings"]["resolution"]; onChange((current) => ({ ...current, imageSettings: { ...imageSettings(current), resolution } })); }} /></PropRow>
</PropSection>
<PropSection title="Style" persistKey="image.style">
<PropRow label="Mode" htmlFor={rootField("mode")}><ComboBox id={rootField("mode")} aria-label="Mode" value={scene.style.mode} options={[{ value: "photo", label: "Photo" }, { value: "art", label: "Art" }]} onChange={(value) => commit({ ...scene, style: { ...scene.style, mode: value as "photo" | "art" } })} /></PropRow>
diff --git a/src/components/workspace/ImageExportView.tsx b/src/components/workspace/ImageExportView.tsx
index 8724156..63fb46c 100644
--- a/src/components/workspace/ImageExportView.tsx
+++ b/src/components/workspace/ImageExportView.tsx
@@ -1,3 +1,4 @@
+import { imageSettings } from "../../lib/imageSettings";
import { invoke } from "@tauri-apps/api/core";
import { useState } from "react";
import { closestExportAspectRatio, exportSizeChoices } from "../../lib/export";
@@ -59,7 +60,7 @@ export function ImageExportView({ config, folderPath }: { config: ProjectConfig;
/* Match presets to the selected image, including imported or resized images
whose dimensions differ from their saved generation settings. */
const original = output?.width && output?.height ? { width: output.width, height: output.height } : null;
- const aspectRatio = original ? closestExportAspectRatio(original) : output?.imageGeneration?.aspectRatio ?? config.settings.aspectRatio;
+ const aspectRatio = original ? closestExportAspectRatio(original) : output?.imageGeneration?.aspectRatio ?? imageSettings(config).aspectRatio;
const sizes = exportSizeChoices(original, aspectRatio, "original")
.map((size, index) => original && index === 0 ? { ...size, value: "original" } : size);
const [chosenSize, setChosenSize] = useState<string | null>(null);
diff --git a/src/lib/extendImage.ts b/src/lib/extendImage.ts
index 82265e6..970a0cd 100644
--- a/src/lib/extendImage.ts
+++ b/src/lib/extendImage.ts
@@ -1,3 +1,4 @@
+import { imageSettings } from "./imageSettings";
import { createImageEditScene } from "./imageScene";
import { compileImagePrompt } from "./imagePrompt";
import { outputDimensions } from "./export";
@@ -38,7 +39,7 @@ export function initialExtendBounds(width: number, height: number): ExtendBounds
}
export function extendOutputDimensions(config: ProjectConfig, source: { width: number; height: number }, bounds: ExtendBounds) {
- const selected = outputDimensions(config.settings.resolution, config.settings.aspectRatio);
+ const selected = outputDimensions(imageSettings(config).resolution, imageSettings(config).aspectRatio);
const pixelBudget = Math.min(source.width * source.height, selected.width * selected.height, EXTEND_MAX_PIXELS);
const scale = Math.min(1, Math.sqrt(pixelBudget / (bounds.width * bounds.height)), EXTEND_MAX_EDGE / bounds.width, EXTEND_MAX_EDGE / bounds.height);
const width = Math.floor(bounds.width * scale / EXTEND_GRID) * EXTEND_GRID;
@@ -95,7 +96,7 @@ export function compileExtendImage(config: ProjectConfig, source: ProjectAsset,
const scene = createImageEditScene({ relativePath: sourceRelativePath, name: source.name, ...output });
scene.steps = options.steps; scene.seed = options.seed;
scene.nodes[0].description = "A wider view of the source scene, as if the view were zoomed out. Continue the same surroundings beyond the visible edges, matching perspective, scale, lighting and textures. One continuous scene, with the original content in its existing position. " + options.prompt.trim();
- const compiled = compileImagePrompt({ ...config, settings: { ...config.settings, defaultLook: null }, imageScene: scene }, { sourceTreatment: "outpaint" });
+ const compiled = compileImagePrompt({ ...config, imageSettings: { ...imageSettings(config), defaultLook: null }, imageScene: scene }, { sourceTreatment: "outpaint" });
// Preserve the original throughout denoising while generating every new
// region together. Separate border passes break shared context at the seams.
const edits = [{ ...preserved, prompt: compiled.prompt, feather: 0, invertMask: true }];
diff --git a/src/lib/imageEditing.ts b/src/lib/imageEditing.ts
index c80fea4..a7aa385 100644
--- a/src/lib/imageEditing.ts
+++ b/src/lib/imageEditing.ts
@@ -1,3 +1,4 @@
+import { imageSettings } from "./imageSettings";
import { createImageEditScene, createImageScene, imageSourceSchema, type ImageNode, type ImageSource } from "./imageScene";
import { compileImagePrompt } from "./imagePrompt";
import type { ProjectConfig, ProjectReference } from "./project";
@@ -30,7 +31,7 @@ export function compileImageEdits(config: ProjectConfig): { source: ImageSource;
const description = ["The edited keyframe corresponds to <Picture 1> with the following change. Preserve the composition and any previously completed edits.", node.description,
node.text ? `Render the exact text "${node.text}".` : ""].filter(Boolean).join(" ");
const editScene = { ...createImageScene(description), rootType: "image" as const, sourceImage: source, referenceIds: [] };
- const compiled = compileImagePrompt({ ...config, settings: { ...config.settings, defaultLook: null }, imageScene: editScene });
+ const compiled = compileImagePrompt({ ...config, imageSettings: { ...imageSettings(config), defaultLook: null }, imageScene: editScene });
return { prompt: compiled.prompt, references: compiled.references, x, y, width: Math.max(1, right - x), height: Math.max(1, bottom - y) };
});
if (!edits.length) throw new Error("Enter a whole-image edit prompt or add an Edit node before generating.");
diff --git a/src/lib/imageHistory.test.ts b/src/lib/imageHistory.test.ts
index 6fc8e75..5614a7d 100644
--- a/src/lib/imageHistory.test.ts
+++ b/src/lib/imageHistory.test.ts
@@ -60,7 +60,10 @@ describe("generated image history", () => {
const reopened = parseProjectConfig(JSON.parse(JSON.stringify(config)));
const restored = restoreGeneratedImage(reopened, "result");
expect(restored.imageScene).toEqual({ ...snapshot.scene, outputAssetId: "result" });
- expect(restored.settings).toMatchObject({ resolution: "1088p", aspectRatio: "4:5", defaultLook: "watercolor" });
+ expect(restored.settings).toEqual(config.settings);
+ expect(restored.brief.resolution).toBe(config.brief.resolution);
+ expect(restored.brief.aspectRatio).toBe(config.brief.aspectRatio);
+ expect(restored.imageSettings).toMatchObject({ resolution: "1088p", aspectRatio: "4:5", defaultLook: "watercolor" });
expect(restored.brief.prompt).toBe(snapshot.briefPrompt);
expect(restored.references).toEqual([snapshot.references[0], config.references[1]]);
expect(restored.assets).toEqual(config.assets);
diff --git a/src/lib/imageHistory.ts b/src/lib/imageHistory.ts
index cd64540..0d15cdb 100644
--- a/src/lib/imageHistory.ts
+++ b/src/lib/imageHistory.ts
@@ -1,14 +1,14 @@
import { createImageEditScene, createImageScene, imageSceneReferenceIds, imageScenePromptText, imageSourceSchema } from "./imageScene";
import { actionReferenceIds, type ImageGenerationSnapshot, type ProjectAsset, type ProjectConfig } from "./project";
+import { imageSettings } from "./imageSettings";
export function imageGenerationSnapshot(config: ProjectConfig, prompt: string, generatorTemplateId: string): ImageGenerationSnapshot {
const scene = config.imageScene ?? createImageScene(config.brief.prompt);
const cited = actionReferenceIds(imageScenePromptText(scene));
return structuredClone({
scene: { ...scene, outputAssetId: null },
- resolution: config.settings.resolution,
- aspectRatio: config.settings.aspectRatio,
- defaultLook: config.settings.defaultLook ?? null,
+ ...imageSettings(config),
+ defaultLook: imageSettings(config).defaultLook ?? null,
briefPrompt: config.brief.prompt,
prompt,
generatorTemplateId,
@@ -133,8 +133,8 @@ export function restoreGeneratedImage(config: ProjectConfig, id: string): Projec
const references = new Map(restored.references.map((reference) => [reference.id, reference]));
return { ...config, thumbnail: asset.relativePath ?? null,
imageScene: { ...scene, outputAssetId: id },
- settings: { ...config.settings, resolution: restored.resolution, aspectRatio: restored.aspectRatio, defaultLook: restored.defaultLook },
- brief: { ...config.brief, prompt: restored.briefPrompt, resolution: restored.resolution, aspectRatio: restored.aspectRatio },
+ imageSettings: { resolution: restored.resolution, aspectRatio: restored.aspectRatio, defaultLook: restored.defaultLook },
+ brief: { ...config.brief, prompt: restored.briefPrompt },
references: [...config.references.map((reference) => references.get(reference.id) ?? reference),
...restored.references.filter((reference) => !config.references.some((current) => current.id === reference.id))],
};
diff --git a/src/lib/imagePrompt.ts b/src/lib/imagePrompt.ts
index 50cf0fd..32482ed 100644
--- a/src/lib/imagePrompt.ts
+++ b/src/lib/imagePrompt.ts
@@ -1,3 +1,4 @@
+import { imageSettings } from "./imageSettings";
import { createImageScene, imageScenePromptParts, imageScenePromptText } from "./imageScene";
import { actionReferenceIds, activeReferenceRefmods, isVideoReference, referenceDefinition, referenceImages, splitActionText, type ProjectConfig } from "./project";
import { SHOT_TAG_GROUPS } from "./shot-tags";
@@ -32,7 +33,7 @@ export function compileImagePrompt(config: ProjectConfig, options: { referenceTr
return [{ id: reference.id, name: reference.name, role, description, source: sources.length ? ` from ${sources.join(" and ")}` : "" }];
});
if (picture > 9) throw new Error("MiniMax H3 supports at most nine reference images per generation.");
- const look = SHOT_TAG_GROUPS.find((group) => group.id === "visualStyle")?.options.find((option) => option.id === config.settings.defaultLook)?.label;
+ const look = SHOT_TAG_GROUPS.find((group) => group.id === "visualStyle")?.options.find((option) => option.id === imageSettings(config).defaultLook)?.label;
const parts = imageScenePromptParts(scene, look);
if (!parts) return { prompt: "", references };
const label = (index: number) => `<Subject ${index + 1}>`;
diff --git a/src/lib/imageSettings.ts b/src/lib/imageSettings.ts
new file mode 100644
index 0000000..f4d1fba
--- /dev/null
+++ b/src/lib/imageSettings.ts
@@ -0,0 +1,7 @@
+import type { ProjectConfig } from "./project";
+
+/** Legacy images inherit project defaults until their own settings are saved. */
+export function imageSettings(config: ProjectConfig): NonNullable<ProjectConfig["imageSettings"]> {
+ const settings = config.imageSettings ?? config.settings;
+ return { resolution: settings.resolution, aspectRatio: settings.aspectRatio, defaultLook: settings.defaultLook };
+}
diff --git a/src/lib/project.ts b/src/lib/project.ts
index cd3f47e..393889d 100644
--- a/src/lib/project.ts
+++ b/src/lib/project.ts
@@ -639,6 +639,11 @@ export const projectConfigSchema = z.object({
schemaVersion: z.literal(CURRENT_SCHEMA_VERSION),
generationType: generationTypeSchema.default("video"),
imageScene: imageSceneSchema.nullish(),
+ imageSettings: z.object({
+ resolution: resolutionSchema,
+ aspectRatio: aspectRatioSchema,
+ defaultLook: z.string().regex(SHOT_TAG_ID_PATTERN).nullish(),
+ }).nullish(),
id: idSchema,
name: z.string().min(1).max(120),
createdAt: isoDateSchema,
diff --git a/src/lib/workQueue.test.ts b/src/lib/workQueue.test.ts
index 975da91..5636ac3 100644
--- a/src/lib/workQueue.test.ts
+++ b/src/lib/workQueue.test.ts
@@ -16,6 +16,7 @@ import { downloadTemplateWeights, getWeightDownloadState } from "./weightDownloa
import { compileImagePrompt } from "./imagePrompt";
import { addImageNode, createImageEditScene } from "./imageScene";
import { createEmptyImage, makeImagePrimary, restoreGeneratedImage } from "./imageHistory";
+import { sceneGenerationRequest } from "./sceneGeneration";
vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));
vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn() }));
@@ -164,20 +165,26 @@ 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("generates an image in a video project and preserves its video scenes", async () => {
+ it("generates an image at its own resolution and preserves the video generation canvas after reopening", async () => {
const { queue, first } = setup();
const original = first.getSnapshot().config;
+ first.update((current) => ({ ...current, imageSettings: { resolution: "768p", aspectRatio: "1:1" } }));
vi.mocked(invoke).mockResolvedValue({ relativePath: "media/generated/poster.jpg", width: 768, height: 768 });
queue.enqueueImage(first, template);
await waitFor(() => expect(enqueueSlopfabGeneration).toHaveBeenCalledOnce());
const request = vi.mocked(enqueueSlopfabGeneration).mock.calls[0][0];
- expect(request).toMatchObject({ stillImage: true, frames: 1 });
+ expect(request).toMatchObject({ stillImage: true, frames: 1, canvasWidth: 768, canvasHeight: 768 });
await finish(queue, request.jobId);
const reopened = parseProjectConfig(JSON.parse(JSON.stringify(first.getSnapshot().config)));
expect(reopened.imageScene?.outputAssetId).toBeTruthy();
expect(reopened.assets.some((asset) => asset.relativePath === "media/generated/poster.jpg")).toBe(true);
expect(reopened.generationJobs).toEqual(original.generationJobs);
expect(reopened.timeline).toEqual(original.timeline);
+ expect(reopened.settings).toEqual(original.settings);
+ expect(reopened.brief).toEqual(original.brief);
+ expect(reopened.assets[0].imageGeneration).toMatchObject({ resolution: "768p", aspectRatio: "1:1" });
+ expect(sceneGenerationRequest(reopened.generationJobs[0], reopened, "C:/First", 20))
+ .toMatchObject({ canvasWidth: 736, canvasHeight: 416 });
});
it.each([-1, 0, Number.MAX_SAFE_INTEGER])("saves the exact submitted image seed without changing the authored seed (%s)", async (seed) => {
const { queue, saved } = setup();
diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.ts
index 08421e5..51b5169 100644
--- a/src/lib/workQueue.ts
+++ b/src/lib/workQueue.ts
@@ -1,3 +1,4 @@
+import { imageSettings } from "./imageSettings";
import { listen } from "@tauri-apps/api/event";
import { invoke } from "@tauri-apps/api/core";
import { createImageEditScene, createImageScene, imageScenePrompt } from "./imageScene";
@@ -275,7 +276,7 @@ export class WorkQueue {
...(edit ? [projectItemPath(session.record.folderPath, edit.source)!] : []),
...selected.flatMap((reference) => referenceImages(reference).map((image) => projectItemPath(session.record.folderPath, image)!)),
];
- const { width, height } = edit?.source ?? outputDimensions(current.settings.resolution, current.settings.aspectRatio);
+ const { width, height } = edit?.source ?? outputDimensions(imageSettings(current).resolution, imageSettings(current).aspectRatio);
const id = `image-${crypto.randomUUID()}`;
const imageDraftId = current.assets.find((asset) => asset.id === scene.outputAssetId && asset.imageDraft)?.id;
// Generating again from a finished image makes a new image in its family.
@@ -350,7 +351,7 @@ export class WorkQueue {
config.imageScene = { ...(config.imageScene ?? createImageScene()),
steps: generationStepsWithLoras(options?.steps ?? current.imageScene?.steps ?? template.defaultSteps, config),
seed: options?.seed ?? current.imageScene?.seed ?? -1 };
- const dimensions = characterSheetDimensions(config.settings.resolution, options?.height);
+ const dimensions = characterSheetDimensions(imageSettings(config).resolution, options?.height);
const indices = characterSheetViewIndices(options);
const order = CHARACTER_SHEET_ORDER.filter((index) => indices.includes(index));
const firstView = order[0];