Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Regenerate crops inside Extend boxes

Bittib4363df21f1a
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index e48ae3e..a62b266 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -4,7 +4,7 @@ This alpha update adds SeedVR2 and Real-ESRGAN export upscaling, Long Shot and B
## What's new
-- **Extend image template restored.** Draw or resize the output box, choose a generation resolution, and optionally describe the new surroundings. Output follows the box's aspect ratio and selected pixel budget, resizing the source to fit. Positioned source conditioning keeps the scene anchored, while generated edges blend into the original with seam tone matching.
+- **Extend image template restored.** Draw or resize the output box, choose a generation resolution, and optionally describe the new surroundings. Output follows the box's aspect ratio and selected pixel budget, resizing the source to fit. Boxes inside the source regenerate the selected crop with refined detail at the target resolution. Positioned source conditioning keeps the scene anchored, while generated edges blend into the original with seam tone matching.
- **SeedVR2 upscaling for images and videos.** Restore exports at the selected output size using SeedVR2 3B FP16 and its VAE. Run on the local NVIDIA CUDA GPU or a selected CUDA LAN worker. Workers download missing standard weights or receive your selected local weight files.
- **Real-ESRGAN upscaling for images and videos.** Use RealESRGAN x4plus during export, with the result resized to your chosen output dimensions. CUDA and Vulkan are supported. Choose None to export without an upscaler.
- **Other weights settings.** Settings → Generator now includes downloads and optional local file paths for Real-ESRGAN, SeedVR2 and the MiniMax H3 latent upscaler. Upscaler downloads share the generator and LoRA download queue, with progress and cancellation in Work Queue.
diff --git a/src-tauri/core/src/slopfab/ffi/mod.rs b/src-tauri/core/src/slopfab/ffi/mod.rs
index 1069654..999e1f0 100644
--- a/src-tauri/core/src/slopfab/ffi/mod.rs
+++ b/src-tauri/core/src/slopfab/ffi/mod.rs
@@ -110,13 +110,13 @@ impl Api {
self.check(r)?;
self.inner.set_still_image(r.pointer.as_ptr())
}
- pub fn set_image_edit_path(&self, r: &RequestHandle, path: &Path, bounds: [i32; 4], feather: i32) -> Result<(), String> {
+ pub fn set_image_edit_path(&self, r: &RequestHandle, path: &Path, bounds: [i32; 4], strength: f32, feather: i32) -> Result<(), String> {
self.check(r)?;
- self.inner.set_image_edit_path(r.pointer.as_ptr(), path, bounds, feather)
+ self.inner.set_image_edit_path(r.pointer.as_ptr(), path, bounds, strength, feather)
}
- pub fn set_image_edit_rgb(&self, r: &RequestHandle, pixels: &[u8], width: i32, height: i32, bounds: [i32; 4], feather: i32) -> Result<(), String> {
+ pub fn set_image_edit_rgb(&self, r: &RequestHandle, pixels: &[u8], width: i32, height: i32, bounds: [i32; 4], strength: f32, feather: i32) -> Result<(), String> {
self.check(r)?;
- self.inner.set_image_edit_rgb(r.pointer.as_ptr(), pixels, width, height, bounds, feather)
+ self.inner.set_image_edit_rgb(r.pointer.as_ptr(), pixels, width, height, bounds, strength, feather)
}
pub fn set_image_edit_invert_mask(&self, r: &RequestHandle) -> Result<(), String> {
self.check(r)?;
diff --git a/src-tauri/core/src/slopfab/ffi/raw/mod.rs b/src-tauri/core/src/slopfab/ffi/raw/mod.rs
index d018c61..3dd15b6 100644
--- a/src-tauri/core/src/slopfab/ffi/raw/mod.rs
+++ b/src-tauri/core/src/slopfab/ffi/raw/mod.rs
@@ -455,17 +455,17 @@ impl Api {
let set = self.set_still_image.ok_or("This slopfab.dll does not support still-image generation. Update the runtime to generate images and reference icons.")?;
self.error(unsafe { set(r, 1) })
}
- pub fn set_image_edit_path(&self, r: *mut Request, path: &Path, bounds: [i32; 4], feather: i32) -> Result<(), String> {
+ pub fn set_image_edit_path(&self, r: *mut Request, path: &Path, bounds: [i32; 4], strength: f32, feather: i32) -> Result<(), String> {
let set = self.set_image_edit_path.ok_or("This slopfab.dll does not support bounding-box image editing. Update the runtime.")?;
let path = path_cstring(path)?;
- self.error(unsafe { set(r, path.as_ptr(), bounds[0], bounds[1], bounds[2], bounds[3], 1.0, feather) })
+ self.error(unsafe { set(r, path.as_ptr(), bounds[0], bounds[1], bounds[2], bounds[3], strength, feather) })
}
- pub fn set_image_edit_rgb(&self, r: *mut Request, pixels: &[u8], width: i32, height: i32, bounds: [i32; 4], feather: i32) -> Result<(), String> {
+ pub fn set_image_edit_rgb(&self, r: *mut Request, pixels: &[u8], width: i32, height: i32, bounds: [i32; 4], strength: f32, feather: i32) -> Result<(), String> {
let set = self.set_image_edit_rgb.ok_or("This slopfab.dll does not support sequential image editing. Update the runtime.")?;
if width <= 0 || height <= 0 || pixels.len() != width as usize * height as usize * 3 {
return Err("Invalid image edit RGB buffer.".into());
}
- self.error(unsafe { set(r, pixels.as_ptr(), pixels.len(), width, height, width as usize * 3, bounds[0], bounds[1], bounds[2], bounds[3], 1.0, feather) })
+ self.error(unsafe { set(r, pixels.as_ptr(), pixels.len(), width, height, width as usize * 3, bounds[0], bounds[1], bounds[2], bounds[3], strength, feather) })
}
pub fn set_image_edit_invert_mask(&self, r: *mut Request) -> Result<(), String> {
let set = self.set_image_edit_invert_mask.ok_or("Seamless Extend requires SlopFab API 1.20 or later. Update the generation runtime.")?;
diff --git a/src-tauri/core/src/slopfab/ffi/tests.rs b/src-tauri/core/src/slopfab/ffi/tests.rs
index 6e92789..269d3c0 100644
--- a/src-tauri/core/src/slopfab/ffi/tests.rs
+++ b/src-tauri/core/src/slopfab/ffi/tests.rs
@@ -22,18 +22,18 @@ fn image_edit_setters_use_original_pixel_boxes_and_pad_the_plan() {
let api = Api::load(&crate::slopfab::default_dll_path()).unwrap();
let request = RequestHandle::new(&api).unwrap();
let pixels = vec![100; 65 * 41 * 3];
- api.set_image_edit_rgb(&request, &pixels, 65, 41, [60, 35, 5, 6], 0).unwrap();
+ api.set_image_edit_rgb(&request, &pixels, 65, 41, [60, 35, 5, 6], 1.0, 0).unwrap();
let plan = api.resolve(&request).unwrap();
assert_eq!((plan.canvas_width, plan.canvas_height, plan.aligned_frames), (96, 64, 1));
- assert!(api.set_image_edit_rgb(&request, &pixels, 65, 41, [60, 35, 6, 6], 0).is_err());
- assert!(api.set_image_edit_rgb(&request, &pixels[..3], 65, 41, [0, 0, 5, 6], 0).is_err());
- assert!(api.set_image_edit_rgb(&request, &pixels, 65, 41, [60, 35, 5, 6], -1).is_err());
+ assert!(api.set_image_edit_rgb(&request, &pixels, 65, 41, [60, 35, 6, 6], 1.0, 0).is_err());
+ assert!(api.set_image_edit_rgb(&request, &pixels[..3], 65, 41, [0, 0, 5, 6], 1.0, 0).is_err());
+ assert!(api.set_image_edit_rgb(&request, &pixels, 65, 41, [60, 35, 5, 6], 1.0, -1).is_err());
assert_eq!(api.resolve(&request).unwrap().canvas_width, 96);
let folder = tempfile::tempdir().unwrap();
let path = folder.path().join("source.png");
image::RgbImage::from_raw(65, 41, pixels).unwrap().save(&path).unwrap();
let from_path = RequestHandle::new(&api).unwrap();
- api.set_image_edit_path(&from_path, &path, [0, 0, 65, 41], 16).unwrap();
+ api.set_image_edit_path(&from_path, &path, [0, 0, 65, 41], 1.0, 16).unwrap();
std::fs::remove_file(path).unwrap(); // The setter snapshots pixels synchronously.
assert_eq!(api.resolve(&from_path).unwrap().aligned_frames, 1);
}
@@ -43,7 +43,7 @@ fn older_runtimes_reject_outpainting_instead_of_editing_the_original() {
let mut api = Api::load(&crate::slopfab::default_dll_path()).unwrap();
api.disable_outpainting_for_test();
let request = RequestHandle::new(&api).unwrap();
- api.set_image_edit_rgb(&request, &vec![127; 64 * 64 * 3], 64, 64, [16, 16, 32, 32], 0).unwrap();
+ api.set_image_edit_rgb(&request, &vec![127; 64 * 64 * 3], 64, 64, [16, 16, 32, 32], 1.0, 0).unwrap();
assert!(api.set_image_edit_invert_mask(&request).unwrap_err().contains("API 1.20"));
// Ordinary image editing remains available on older runtimes.
assert!(api.resolve(&request).is_ok());
diff --git a/src-tauri/core/src/slopfab/h3.rs b/src-tauri/core/src/slopfab/h3.rs
index 459fa62..a4b470b 100644
--- a/src-tauri/core/src/slopfab/h3.rs
+++ b/src-tauri/core/src/slopfab/h3.rs
@@ -72,10 +72,14 @@ pub(super) fn configure_request(
// Ordinary edits blend inward. Outpainting preserves this box and
// generates its entire surround with shared context in one pass.
let feather = step.feather.unwrap_or(16);
+ let strength = step.strength.unwrap_or(1.0);
+ if !strength.is_finite() || strength <= 0.0 || strength > 1.0 {
+ return Err("Image edit strength must be greater than zero and at most one.".into());
+ }
if let Some(pixels) = &request.image_edit_pixels {
- api.set_image_edit_rgb(handle, pixels, request.canvas_width, request.canvas_height, bounds, feather)?;
+ api.set_image_edit_rgb(handle, pixels, request.canvas_width, request.canvas_height, bounds, strength, feather)?;
} else {
- api.set_image_edit_path(handle, request.image_edit_path.as_deref().ok_or("Image edit source has not been resolved.")?, bounds, feather)?;
+ api.set_image_edit_path(handle, request.image_edit_path.as_deref().ok_or("Image edit source has not been resolved.")?, bounds, strength, feather)?;
}
if step.invert_mask {
api.set_image_edit_invert_mask(handle)?;
diff --git a/src-tauri/core/src/slopfab/planning.rs b/src-tauri/core/src/slopfab/planning.rs
index bc97fb2..a7e492a 100644
--- a/src-tauri/core/src/slopfab/planning.rs
+++ b/src-tauri/core/src/slopfab/planning.rs
@@ -84,6 +84,9 @@ pub(super) fn validate_generation_controls(request: &GenerationRequest) -> Resul
return Err("Image edits require one source image and nonempty boxes inside its dimensions.".into());
}
for step in &edit.edits {
+ if step.strength.is_some_and(|strength| !strength.is_finite() || strength <= 0.0 || strength > 1.0) {
+ return Err("Image edit strength must be greater than zero and at most one.".into());
+ }
if step.invert_mask && (edit.edits.len() != 1 || step.feather != Some(0)
|| (step.x == 0 && step.y == 0 && step.width == request.canvas_width && step.height == request.canvas_height)
|| (i64::from(step.x) + 15) / 16 >= (i64::from(step.x) + i64::from(step.width)) / 16
diff --git a/src-tauri/core/src/slopfab/tests.rs b/src-tauri/core/src/slopfab/tests.rs
index 879853d..46b96dd 100644
--- a/src-tauri/core/src/slopfab/tests.rs
+++ b/src-tauri/core/src/slopfab/tests.rs
@@ -79,7 +79,7 @@ fn image_edit_recipe_disables_motion_cache_and_keeps_source_geometry() {
canvas_width: 65, canvas_height: 41,
image_edit_pixels: Some(std::sync::Arc::new(vec![100; 65 * 41 * 3])),
image_edit: Some(types::ImageEditRequest { source_relative_path: "media/source.png".into(), edits: vec![
- types::ImageEditStep { prompt: "A red vase".into(), x: 30, y: 10, width: 35, height: 31, feather: None, invert_mask: false, reference_paths: None, refmods: None }
+ types::ImageEditStep { prompt: "A red vase".into(), x: 30, y: 10, width: 35, height: 31, feather: None, strength: None, invert_mask: false, reference_paths: None, refmods: None }
] }), ..Default::default()
};
validate_generation_controls(&request).unwrap();
@@ -110,6 +110,40 @@ fn image_edit_recipe_disables_motion_cache_and_keeps_source_geometry() {
assert!(validate_generation_controls(&invalid).is_err());
}
+#[test]
+fn crop_regeneration_strength_survives_worker_transfer_and_reaches_native_sampling() {
+ let configuration = Configuration::from_settings(&BTreeMap::new());
+ let api = ffi::Api::load(&configuration.dll_path).unwrap();
+ let request: GenerationRequest = serde_json::from_value(serde_json::json!({
+ "jobId":"crop", "prompt":"Refine the crop", "stillImage":true, "frames":1,
+ "steps":20, "seed":0, "canvasWidth":128, "canvasHeight":64,
+ "imageEdit":{"sourceRelativePath":"canvas.png", "edits":[{
+ "prompt":"Refine the crop", "x":0, "y":0, "width":128, "height":64,
+ "feather":0, "strength":0.65
+ }]}
+ })).unwrap();
+ let mut roundtrip: GenerationRequest = serde_json::from_value(serde_json::to_value(&request).unwrap()).unwrap();
+ assert_eq!(roundtrip.image_edit.as_ref().unwrap().edits[0].strength, Some(0.65));
+ roundtrip.image_edit_pixels = Some(std::sync::Arc::new(vec![127; 128 * 64 * 3]));
+ validate_generation_controls(&roundtrip).unwrap();
+ for platform in [ComputePlatform::Cuda13, ComputePlatform::Vulkan] {
+ let plan = |request: &GenerationRequest| {
+ let handle = RequestHandle::new(&api).unwrap();
+ configure_request(&api, &handle, request, &configuration, platform, RequestPurpose::Plan, &ReferenceVideos::default()).unwrap();
+ api.resolve(&handle).unwrap()
+ };
+ let crop = plan(&roundtrip);
+ assert_eq!((crop.canvas_width, crop.canvas_height, crop.aligned_frames), (128, 64, 1));
+ let mut full = roundtrip.clone();
+ full.image_edit.as_mut().unwrap().edits[0].strength = None;
+ assert!(crop.num_model_evaluations > 0 && crop.num_model_evaluations < plan(&full).num_model_evaluations);
+ }
+ for strength in [0.0, -0.1, 1.1, f32::NAN, f32::INFINITY] {
+ roundtrip.image_edit.as_mut().unwrap().edits[0].strength = Some(strength);
+ assert!(validate_generation_controls(&roundtrip).is_err());
+ }
+}
+
#[test]
fn outpainting_preserves_one_box_in_preview_execution_and_worker_requests() {
let mut configuration = Configuration::from_settings(&BTreeMap::new());
diff --git a/src-tauri/core/src/slopfab/types.rs b/src-tauri/core/src/slopfab/types.rs
index a0eed2e..3575abb 100644
--- a/src-tauri/core/src/slopfab/types.rs
+++ b/src-tauri/core/src/slopfab/types.rs
@@ -128,6 +128,9 @@ pub struct ImageEditStep {
pub height: i32,
#[serde(default)]
pub feather: Option<i32>,
+ /// Denoising strength, defaulting to a full edit for existing requests.
+ #[serde(default)]
+ pub strength: Option<f32>,
/// Outpainting: preserve the box and generate all surrounding pixels together.
#[serde(default)]
pub invert_mask: bool,
diff --git a/src-tauri/src/commands/extend_image.rs b/src-tauri/src/commands/extend_image.rs
index 34ba70f..948bd30 100644
--- a/src-tauri/src/commands/extend_image.rs
+++ b/src-tauri/src/commands/extend_image.rs
@@ -63,6 +63,9 @@ fn scaled_layout(
.into(),
);
}
+ if bounds.is_contained(workspace.width, workspace.height) {
+ return Ok((output, ExtendBounds { x: 0, y: 0, width: output.width, height: output.height }));
+ }
let scale = (output.width as f64 / bounds.width as f64)
.min(output.height as f64 / bounds.height as f64);
let source = ExtendSize {
@@ -81,10 +84,19 @@ fn scaled_layout(
height: output.height,
};
mapped.validate(source.width, source.height)?;
+ if mapped.is_contained(source.width, source.height) {
+ return Err("Expand the box further or increase the resolution to generate the extension.".into());
+ }
Ok((source, mapped))
}
impl ExtendBounds {
+ fn is_contained(self, width: u32, height: u32) -> bool {
+ self.x >= 0 && self.y >= 0
+ && i64::from(self.x) + i64::from(self.width) <= i64::from(width)
+ && i64::from(self.y) + i64::from(self.height) <= i64::from(height)
+ }
+
fn validate(self, width: u32, height: u32) -> Result<(), String> {
if width == 0
|| height == 0
@@ -104,9 +116,6 @@ impl ExtendBounds {
if self.x >= width as i32 || self.y >= height as i32 || right <= 0 || bottom <= 0 {
return Err("The Extend box must overlap the original image.".into());
}
- if self.x >= 0 && self.y >= 0 && right <= width as i32 && bottom <= height as i32 {
- return Err("The Extend box must extend beyond the original image.".into());
- }
Ok(())
}
}
@@ -168,7 +177,8 @@ pub(crate) fn prepare_extend_image(
return Err("The Extend source has no saved file.".into());
};
let (width, height) = image::image_dimensions(&source_path).map_err(|e| e.to_string())?;
- let (scaled, bounds) = scaled_layout(width, height, bounds, output)?;
+ let selection = bounds;
+ let (scaled, bounds) = scaled_layout(width, height, selection, output)?;
if asset.width != Some(width) || asset.height != Some(height) {
return Err(
"The source image dimensions changed. Reopen the image before extending it.".into(),
@@ -177,6 +187,18 @@ pub(crate) fn prepare_extend_image(
let mut source = image::open(source_path)
.map_err(|e| e.to_string())?
.to_rgba8();
+ let workspace = source_dimensions(width, height);
+ if selection.is_contained(workspace.width, workspace.height) {
+ // Crop in original pixels before resizing, so a tiny selection never
+ // allocates a magnified copy of the entire source image.
+ let left = (selection.x as u64 * width as u64 / workspace.width as u64) as u32;
+ let top = (selection.y as u64 * height as u64 / workspace.height as u64) as u32;
+ let right = ((selection.x as u64 + selection.width as u64) * width as u64)
+ .div_ceil(workspace.width as u64) as u32;
+ let bottom = ((selection.y as u64 + selection.height as u64) * height as u64)
+ .div_ceil(workspace.height as u64) as u32;
+ source = image::imageops::crop_imm(&source, left, top, right - left, bottom - top).to_image();
+ }
if source.dimensions() != (scaled.width, scaled.height) {
source = image::imageops::resize(
&source,
@@ -186,8 +208,8 @@ pub(crate) fn prepare_extend_image(
);
}
let cache = root.directory(&directory(&job_id)?)?;
- // Snapshot the resized original. Generation and final preservation use
- // exactly these pixels, with no second resampling.
+ // Snapshot the resized source or crop. Outpainting's final preservation
+ // uses exactly these pixels, with no second resampling.
write_png(&cache.join("original.png"), &source)?;
write_png(&cache.join("canvas.png"), &padded_source(&source, bounds))?;
crate::storage::atomic::write_atomically(
@@ -368,7 +390,9 @@ pub(crate) fn save_extended_image(
let (_, pixels) = crate::rendered::take_still(&job_id)?;
let mut result = RgbaImage::from_raw(bounds.width, bounds.height, pixels)
.ok_or("Invalid generated image pixels.")?;
- restore_original(&mut result, &source, bounds);
+ if !bounds.is_contained(source.width(), source.height()) {
+ restore_original(&mut result, &source, bounds);
+ }
super::artifacts::write_generated_png_frame(
&folder_path,
&job_id,
@@ -411,6 +435,16 @@ mod tests {
#[test]
#[ignore]
fn extend_gpu_smoke() {
+ generation_smoke(false);
+ }
+
+ #[test]
+ #[ignore]
+ fn extend_crop_gpu_smoke() {
+ generation_smoke(true);
+ }
+
+ fn generation_smoke(regenerate: bool) {
use slopus_core::{
settings::{ProviderOption, ProviderSetting},
slopfab::{GenerationRequest, NativeEvent, SlopfabRuntime},
@@ -488,21 +522,18 @@ mod tests {
crate::project::storage::write_project(folder.path(), &config).unwrap();
write_png(&folder.path().join("source.png"), &source).unwrap();
let path = folder.path().to_string_lossy().into_owned();
- let job = "extend-gpu-smoke";
- // A 1.5x square selection rendered at 416p, matching the TS compiler.
+ let job = if regenerate { "extend-crop-gpu-smoke" } else { "extend-gpu-smoke" };
+ let size = if regenerate { 768 } else { 416 };
+ // Exercise extension at 416p or a contained crop regenerated at 768p.
prepare_extend_image(
path.clone(),
job.into(),
"source".into(),
- ExtendBounds {
- x: -64,
- y: -64,
- width: 384,
- height: 384,
- },
+ if regenerate { ExtendBounds { x: 32, y: 32, width: 192, height: 192 } }
+ else { ExtendBounds { x: -64, y: -64, width: 384, height: 384 } },
ExtendSize {
- width: 416,
- height: 416,
+ width: size,
+ height: size,
},
)
.unwrap();
@@ -511,10 +542,19 @@ mod tests {
let canvas = cache.join("canvas.png");
std::fs::copy(&canvas, artifact_dir.join("canvas.png")).unwrap();
let prompt = "integrated_multimodal_description: [Shot 1] Match the source scene's visual style. One continuous scene matching Source scene's setting, perspective, subject scale, lighting and textures. The existing subjects remain at their canvas positions.\n\noverall_soundscape: N/A\n\nnon_diegetic_music: N/A";
+ let prompt = if regenerate {
+ "subject_definitions:\n<Picture 1> is the original source image and composition anchor for the edited still keyframe in [Shot 1], providing the framing, perspective, environment, lighting and visual style.\n\nsummary:\n[keyframe completion] The target is a single edited still keyframe based on <Picture 1>. Apply the described change while preserving all other content.\n\nretention_analysis:\n<Picture 1> ([Shot 1] edited keyframe): partially_preserved - retain its composition and visual characteristics except for the described change. Preserve all other content, including any previously completed edits.\n\ndetailed_description:\nThe still image retains the visual medium, lighting, palette and perspective of <Picture 1>.\n[Shot 1] Refine the selected crop in <Picture 1> at the target resolution. Recover natural fine detail and clean textures while preserving the subjects, composition, perspective, lighting and visual style.\n\noverall_soundscape: N/A\n\nnon_diegetic_music: N/A"
+ } else { prompt };
+ let step = if regenerate {
+ serde_json::json!({"x":0,"y":0,"width":size,"height":size,"strength":0.65,"feather":0,"prompt":prompt})
+ } else {
+ serde_json::json!({"x":85,"y":85,"width":245,"height":245,"invertMask":true,"feather":0,"prompt":prompt})
+ };
let mut request: GenerationRequest = serde_json::from_value(serde_json::json!({
- "jobId":job, "stillImage":true, "frames":1, "steps":20, "seed":17, "canvasWidth":416, "canvasHeight":416, "prompt":prompt,
- "imageEdit":{"sourceRelativePath":"canvas.png", "edits":[{"x":85,"y":85,"width":245,"height":245,"invertMask":true,"feather":0,"prompt":prompt}]}
+ "jobId":job, "stillImage":true, "frames":1, "steps":20, "seed":17, "canvasWidth":size, "canvasHeight":size, "prompt":prompt,
+ "imageEdit":{"sourceRelativePath":"canvas.png", "edits":[step]}
})).unwrap();
+ if regenerate { request.reference_paths = vec![canvas.to_string_lossy().into_owned()]; }
request.image_edit_path = Some(canvas);
let runtime = SlopfabRuntime::default();
let (send, receive) = mpsc::channel();
@@ -544,7 +584,7 @@ mod tests {
}
}
}
- let raw = RgbaImage::from_raw(416, 416, crate::rendered::frame(job, 0).unwrap().unwrap())
+ let raw = RgbaImage::from_raw(size, size, crate::rendered::frame(job, 0).unwrap().unwrap())
.unwrap();
write_png(&artifact_dir.join("raw.png"), &raw).unwrap();
write_png(&artifact_dir.join("source.png"), &snapshot).unwrap();
@@ -552,16 +592,21 @@ mod tests {
let saved = save_extended_image(path.clone(), job.into()).unwrap();
let final_path = folder.path().join(saved.relative_path);
let result = image::open(&final_path).unwrap().to_rgba8();
- assert_eq!(result.dimensions(), (416, 416));
- for y in 16..snapshot.height() - 16 {
- for x in 16..snapshot.width() - 16 {
- assert_eq!(result.get_pixel(x + 69, y + 69), snapshot.get_pixel(x, y));
+ assert_eq!(result.dimensions(), (size, size));
+ if regenerate {
+ assert_eq!(result, raw, "The finalizer must retain regenerated pixels");
+ assert_ne!(result, snapshot, "Generation must change the resized crop");
+ } else {
+ for y in 16..snapshot.height() - 16 {
+ for x in 16..snapshot.width() - 16 {
+ assert_eq!(result.get_pixel(x + 69, y + 69), snapshot.get_pixel(x, y));
+ }
}
+ assert!(result
+ .enumerate_pixels()
+ .filter(|(x, y, _)| *x < 69 || *y < 69)
+ .any(|(_, _, pixel)| pixel.0 != [127, 127, 127, 255]));
}
- assert!(result
- .enumerate_pixels()
- .filter(|(x, y, _)| *x < 69 || *y < 69)
- .any(|(_, _, pixel)| pixel.0 != [127, 127, 127, 255]));
std::fs::copy(final_path, artifact_dir.join("result.png")).unwrap();
discard_extend_image(path, job.into()).unwrap();
eprintln!("Inspect {}", artifact_dir.join("result.png").display());
@@ -896,11 +941,6 @@ mod tests {
assert_eq!(image::open(original_path).unwrap().to_rgba8(), snapshot);
for invalid in [
ExtendBounds { x: 224, ..bounds },
- ExtendBounds {
- x: 0,
- width: 224,
- ..bounds
- },
ExtendBounds {
width: 8193,
..bounds
@@ -937,6 +977,49 @@ mod tests {
discard_extend_image(path, "extend-test".into()).unwrap();
}
+ #[test]
+ fn contained_selection_crops_original_pixels_and_saves_regenerated_output() {
+ struct GeneratedPixels;
+ impl crate::rendered::FrameSource for GeneratedPixels {
+ fn frame_rgba(&self, _: u32, width: u32, height: u32) -> Result<Vec<u8>, String> {
+ Ok([210, 180, 150, 255].repeat(width as usize * height as usize))
+ }
+ }
+ let folder = tempfile::tempdir().unwrap();
+ let mut config = crate::tests::created_fixture();
+ config.assets.push(serde_json::from_value(serde_json::json!({
+ "id":"source", "kind":"image", "name":"Source", "relativePath":"media/source.png", "mimeType":"image/png",
+ "width":128, "height":96, "createdAt":config.created_at
+ })).unwrap());
+ crate::project::storage::write_project(folder.path(), &config).unwrap();
+ let path = folder.path().to_string_lossy().into_owned();
+ let root = ProjectRoot::open(&path).unwrap();
+ let job = "extend-crop-finalizer-test";
+ let source = RgbaImage::from_fn(128, 96, |x, y| image::Rgba([x as u8, y as u8, 80, 255]));
+ write_png(&root.directory("media").unwrap().join("source.png"), &source).unwrap();
+ prepare_extend_image(path.clone(), job.into(), "source".into(),
+ ExtendBounds { x: 32, y: 32, width: 64, height: 32 }, ExtendSize { width: 256, height: 128 }).unwrap();
+ let crop = image::imageops::crop_imm(&source, 32, 32, 64, 32).to_image();
+ let expected = image::imageops::resize(&crop, 256, 128, image::imageops::FilterType::Lanczos3);
+ let cache = root.path().join(directory(job).unwrap());
+ for file in ["original.png", "canvas.png"] {
+ assert_eq!(image::open(cache.join(file)).unwrap().to_rgba8(), expected);
+ }
+ let bounds: ExtendBounds = serde_json::from_slice(&std::fs::read(cache.join("bounds.json")).unwrap()).unwrap();
+ assert_eq!((bounds.x, bounds.y, bounds.width, bounds.height), (0, 0, 256, 128));
+ crate::rendered::keep(crate::rendered::from_source(job, Box::new(GeneratedPixels), vec![], 1,
+ 256, 128, 3, 256 * 128 * 3, 24.0, 0, 0).unwrap());
+ let saved = save_extended_image(path.clone(), job.into()).unwrap();
+ let result = image::open(root.existing(&saved.relative_path).unwrap()).unwrap().to_rgba8();
+ assert_eq!(result, RgbaImage::from_pixel(256, 128, image::Rgba([210, 180, 150, 255])));
+ assert!(crate::rendered::summary(job).is_none());
+ // Even a tiny box in a large source is prepared at bounded output size.
+ let (scaled, mapped) = scaled_layout(8192, 8192,
+ ExtendBounds { x: 100, y: 100, width: 32, height: 32 }, ExtendSize { width: 768, height: 768 }).unwrap();
+ assert_eq!((scaled.width, scaled.height, mapped.x, mapped.y), (768, 768, 0, 0));
+ discard_extend_image(path, job.into()).unwrap();
+ }
+
#[test]
fn extend_finalizer_preserves_downscaled_source_pixels_in_a_bounded_png() {
struct GeneratedPixels;
diff --git a/src/components/workspace/Extend.test.tsx b/src/components/workspace/Extend.test.tsx
index 2f3fabc..f19f9c4 100644
--- a/src/components/workspace/Extend.test.tsx
+++ b/src/components/workspace/Extend.test.tsx
@@ -139,3 +139,30 @@ it.each([0.5, 2])("snaps within six screen pixels at %sx scale without trapping
fireEvent.keyDown(screen.getByRole("button", { name: "Move Extend box" }), { key: "ArrowLeft" });
expect(latest).toEqual({ x: -1, y: 0, width: 384, height: 288 });
});
+
+
+it("executes a contained selection as crop regeneration", () => {
+ vi.spyOn(persistence, "readMediaFileUrl").mockResolvedValue(null);
+ vi.spyOn(persistence, "isTauri").mockReturnValue(true);
+ vi.spyOn(settings, "templateUsable").mockReturnValue(true);
+ const generator = settings.createGeneratorTemplate("Extend generator");
+ settings.saveGeneratorTemplateSettings({ templates: [generator], defaultTemplateId: generator.id });
+ const initial = parseProjectConfig(fixture);
+ initial.assets = [source]; initial.imageScene!.outputAssetId = source.id;
+ const execute = vi.fn();
+ function Harness() {
+ const [config, setConfig] = useState(initial);
+ return <ImageEditor config={config} folderPath="D:/Images" onChange={setConfig} onGenerate={vi.fn()} onCancel={vi.fn()} onGenerateExtend={execute} />;
+ }
+ render(<Harness />);
+ fireEvent.click(screen.getByRole("button", { name: "Template" }));
+ fireEvent.click(screen.getByRole("menuitem", { name: "Extend" }));
+ for (const [field, value] of Object.entries({ x: 32, y: 32, width: 128, height: 96 })) {
+ fireEvent.change(screen.getByLabelText(`Extend ${field}`), { target: { value: String(value) } });
+ }
+ expect(screen.getByText(/Regenerate selection:/)).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "Execute" })).toBeEnabled();
+ fireEvent.click(screen.getByRole("button", { name: "Execute" }));
+ expect(execute).toHaveBeenCalledWith(expect.objectContaining({ id: generator.id }), source.id,
+ expect.objectContaining({ bounds: { x: 32, y: 32, width: 128, height: 96 } }));
+});
diff --git a/src/components/workspace/ExtendSettings.tsx b/src/components/workspace/ExtendSettings.tsx
index 953a521..dd8ccc9 100644
--- a/src/components/workspace/ExtendSettings.tsx
+++ b/src/components/workspace/ExtendSettings.tsx
@@ -16,7 +16,7 @@ export function ExtendSettings({ config, source, options, onChange, onResolution
const validation = useMemo(() => {
try {
const compiled = compileExtendImage(config, source, "cache/extend-preview.png", options);
- return { output: compiled.layout.output, prompt: compiled.prompt, message: null };
+ return { mode: compiled.layout.mode, output: compiled.layout.output, prompt: compiled.prompt, message: null };
}
catch (reason) { return { output: null, prompt: null, message: reason instanceof Error ? reason.message : String(reason) }; }
}, [config, source, options]);
@@ -29,6 +29,7 @@ export function ExtendSettings({ config, source, options, onChange, onResolution
disabled={busy || !onResolutionChange} onChange={(value) => onResolutionChange?.(value)} />
</PropRow>
{validation.output && <p className="image-inspector__caption">Output: {validation.output.width} × {validation.output.height} px</p>}
+ {validation.mode === "regenerate" && <p className="image-inspector__caption">Regenerate selection: refine the selected crop at the output resolution.</p>}
<p className="image-inspector__caption">Source: {source.name} · {source.width} × {source.height} px</p>
{(["x", "y", "width", "height"] as const).map((field) => <PropRow key={field} label={field === "x" ? "X" : field === "y" ? "Y" : field === "width" ? "Width" : "Height"} htmlFor={`extend-${field}`}
tooltip={field === "x" || field === "y" ? "Drag the box or its handles, or drag outside it to draw a new box." : "Sizes use 32-pixel increments. The source is resized to fit the box at the selected generation resolution."}>
@@ -45,7 +46,7 @@ export function ExtendSettings({ config, source, options, onChange, onResolution
<PropRow label="Seed" htmlFor="extend-seed" tooltip="Use -1 for a random seed."><input id="extend-seed" className="text-field" type="number" min="-1" max={Number.MAX_SAFE_INTEGER} step="1" required disabled={busy}
value={Number.isNaN(options.seed) ? "" : options.seed} onChange={(event) => onChange({ ...options, seed: event.target.valueAsNumber })} /></PropRow>
<div className="image-inspector__area"><span>Prompt (optional)</span><PromptTextField aria-label="Extend prompt" value={options.prompt} onChange={(prompt) => onChange({ ...options, prompt })}
- references={references} missingLabel={missingLabel} disabled={busy} placeholder="Describe what should appear beyond the image…" /></div>
+ references={references} missingLabel={missingLabel} disabled={busy} placeholder={validation.mode === "regenerate" ? "Describe details to refine…" : "Describe what should appear beyond the image…"} /></div>
{validation.message && <InfoBar severity="error" title="Adjust the Extend settings" message={validation.message} />}
</div>
<div className="image-template-settings__footer">
diff --git a/src/lib/extendImage.test.ts b/src/lib/extendImage.test.ts
index 3890d1b..d83fef6 100644
--- a/src/lib/extendImage.test.ts
+++ b/src/lib/extendImage.test.ts
@@ -4,7 +4,6 @@ import { createProjectConfig } from "./project";
it("partitions only new pixels for every combination of extension directions and crops", () => {
for (const x of [-3, 0, 2]) for (const y of [-2, 0, 1]) for (const width of [5, 10]) for (const height of [4, 8]) {
- if (x >= 0 && y >= 0 && x + width <= 7 && y + height <= 5) continue;
const { preserved, regions } = extendRegions({ width: 7, height: 5 }, { x, y, width, height });
for (let py = 0; py < height; py++) for (let px = 0; px < width; px++) {
const inside = px + x >= 0 && px + x < 7 && py + y >= 0 && py + y < 5;
@@ -15,10 +14,10 @@ it("partitions only new pixels for every combination of extension directions and
}
});
-it("rejects boxes with no original context, no extension, fractional or excessive dimensions", () => {
+it("rejects boxes with no original context, fractional or excessive dimensions", () => {
for (const bounds of [
{ x: 100, y: 0, width: 20, height: 20 }, { x: -20, y: 0, width: 20, height: 20 },
- { x: 0, y: 0, width: 20, height: 20 }, { x: -1.5, y: 0, width: 20, height: 20 },
+ { x: -1.5, y: 0, width: 20, height: 20 },
{ x: -20, y: 0, width: 8193, height: 20 }, { x: NaN, y: 0, width: 20, height: 20 },
]) expect(() => extendRegions({ width: 100, height: 100 }, bounds)).toThrow();
const large = initialExtendBounds(8192, 400);
@@ -143,3 +142,30 @@ it("aligns resize dimensions while preserving the opposite corner and caps every
expect(Math.max(bounds.width,bounds.height)).toBeLessThanOrEqual(EXTEND_MAX_EDGE);
}
});
+
+
+it("regenerates contained crops and full-image boxes at the target budget", () => {
+ const config = createProjectConfig({ name: "Crop", prompt: "", aspectRatio: "1:1", resolution: "768p", targetDurationSeconds: 15 });
+ const source = { id: "source", name: "Source", kind: "image" as const, mimeType: "image/png", width: 256, height: 256, createdAt: config.createdAt };
+ for (const bounds of [{ x: 32, y: 64, width: 128, height: 96 }, { x: 0, y: 0, width: 256, height: 256 }]) {
+ const compiled = compileExtendImage(config, source, "cache/crop.png", { bounds, prompt: "Fine fur", steps: 20, seed: 0 });
+ expect(compiled.layout.mode).toBe("regenerate");
+ expect(compiled.layout.regions).toEqual([]);
+ expect(compiled.edits).toEqual([{ x: 0, y: 0, ...compiled.layout.output, strength: 0.65, invertMask: false, feather: 0, prompt: compiled.prompt }]);
+ expect(compiled.layout.output.width * compiled.layout.output.height).toBeLessThanOrEqual(768 * 768);
+ expect(compiled.layout.output.width).toBeGreaterThan(bounds.width);
+ expect(compiled.prompt).toContain("Refine the selected crop in <Picture 1>");
+ expect(compiled.prompt).toContain("Fine fur");
+ expect(compiled.scene.sourceImage).toMatchObject(compiled.layout.output);
+ }
+ const small = extendLayout(config, { width: 8192, height: 8192 }, { x: 100, y: 100, width: 32, height: 32 });
+ expect(small).toMatchObject({ mode: "regenerate", source: { width: 768, height: 768 }, bounds: { x: 0, y: 0, width: 768, height: 768 } });
+ const crossing = extendLayout(config, source, { x: -1, y: 64, width: 128, height: 96 });
+ expect(crossing.mode).toBe("outpaint");
+});
+
+
+it("rejects an extension that disappears when mapped to a lower resolution", () => {
+ const config = createProjectConfig({ name: "Extend", prompt: "", aspectRatio: "1:1", resolution: "416p", targetDurationSeconds: 15 });
+ expect(() => extendLayout(config, { width: 1024, height: 1024 }, { x: -1, y: 0, width: 1024, height: 1024 })).toThrow("Expand the box further");
+});
diff --git a/src/lib/extendImage.ts b/src/lib/extendImage.ts
index df3c4a8..24db5b3 100644
--- a/src/lib/extendImage.ts
+++ b/src/lib/extendImage.ts
@@ -51,17 +51,23 @@ export function extendOutputDimensions(config: ProjectConfig, bounds: ExtendBoun
export function extendLayout(config: ProjectConfig, source: { width: number; height: number }, bounds: ExtendBounds) {
const workspace = extendSourceDimensions(source.width, source.height);
- extendRegions(workspace, bounds);
+ const selection = extendRegions(workspace, bounds);
if (bounds.width % EXTEND_GRID || bounds.height % EXTEND_GRID || bounds.width > EXTEND_MAX_EDGE || bounds.height > EXTEND_MAX_EDGE
|| bounds.width * bounds.height > EXTEND_MAX_PIXELS) throw new Error("Use box dimensions in multiples of 32 within the maximum generation resolution.");
const output = extendOutputDimensions(config, bounds);
+ if (!selection.regions.length) {
+ const frame = { x: 0, y: 0, ...output };
+ return { mode: "regenerate" as const, output, source: output, bounds: frame, preserved: frame, regions: [] };
+ }
const scale = Math.min(output.width / bounds.width, output.height / bounds.height);
// A uniform scale preserves the source aspect ratio. Grid rounding adds a
// little generated space instead of stretching the original to fit.
const scaledSource = { width: Math.max(1, Math.round(workspace.width * scale)), height: Math.max(1, Math.round(workspace.height * scale)) };
const mappedBounds = { x: Math.round(bounds.x * scale - (output.width - bounds.width * scale) / 2),
y: Math.round(bounds.y * scale - (output.height - bounds.height * scale) / 2), ...output };
- return { output, source: scaledSource, bounds: mappedBounds, ...extendRegions(scaledSource, mappedBounds) };
+ const mapped = extendRegions(scaledSource, mappedBounds);
+ if (!mapped.regions.length) throw new Error("Expand the box further or increase the resolution to generate the extension.");
+ return { mode: "outpaint" as const, output, source: scaledSource, bounds: mappedBounds, ...mapped };
}
export function extendRegions(source: { width: number; height: number }, bounds: ExtendBounds) {
@@ -80,7 +86,6 @@ export function extendRegions(source: { width: number; height: number }, bounds:
{ x: 0, y: top, width: left, height: bottom - top },
{ x: right, y: top, width: width - right, height: bottom - top },
].filter((region) => region.width > 0 && region.height > 0);
- if (!regions.length) throw new Error("Extend the box beyond at least one edge of the original image.");
return { preserved: { x: left, y: top, width: right - left, height: bottom - top }, regions };
}
@@ -104,15 +109,18 @@ export function compileExtendImage(config: ProjectConfig, source: ProjectAsset,
if (!source.width || !source.height) throw new Error("Wait for the source image dimensions to load.");
const layout = extendLayout(config, { width: source.width, height: source.height }, options.bounds);
const { preserved, output } = layout;
- const context = extendContext(preserved, output);
+ const regenerate = layout.mode === "regenerate";
+ const context = regenerate ? preserved : extendContext(preserved, output);
if (!Number.isInteger(options.steps) || options.steps < 2 || options.steps > 1000) throw new Error("Steps must be a whole number from 2 to 1000.");
if (!Number.isSafeInteger(options.seed) || options.seed < -1) throw new Error("Seed must be -1 for random or a non-negative safe integer.");
const scene = createImageEditScene({ relativePath: sourceRelativePath, name: source.name, ...output });
scene.steps = options.steps; scene.seed = options.seed;
- scene.nodes[0].description = "One continuous scene matching Source scene's setting, perspective, subject scale, lighting and textures. The existing subjects remain at their canvas positions. " + options.prompt.trim();
- const compiled = compileImagePrompt({ ...config, imageSettings: { ...imageSettings(config), defaultLook: null }, imageScene: scene }, { sourceTreatment: "outpaint" });
- // Preserve the interior throughout denoising while generating every new
- // region together. Separate border passes break shared context at the seams.
- const edits = [{ ...context, prompt: compiled.prompt, feather: 0, invertMask: true }];
+ scene.nodes[0].description = (regenerate
+ ? "Refine the selected crop in <Picture 1> at the target resolution. Recover natural fine detail and clean textures while preserving the subjects, composition, perspective, lighting and visual style. "
+ : "One continuous scene matching Source scene's setting, perspective, subject scale, lighting and textures. The existing subjects remain at their canvas positions. ") + options.prompt.trim();
+ const compiled = compileImagePrompt({ ...config, imageSettings: { ...imageSettings(config), defaultLook: null }, imageScene: scene }, regenerate ? {} : { sourceTreatment: "outpaint" });
+ // Outpainting locks the interior and generates all borders together. Crops
+ // refine the whole frame with partial denoising to retain the composition.
+ const edits = [{ ...context, prompt: compiled.prompt, feather: 0, invertMask: !regenerate, ...(regenerate ? { strength: 0.65 } : {}) }];
return { ...compiled, scene, edits, layout };
}
diff --git a/src/lib/extendWork.test.ts b/src/lib/extendWork.test.ts
index 729015b..ef72d67 100644
--- a/src/lib/extendWork.test.ts
+++ b/src/lib/extendWork.test.ts
@@ -144,8 +144,25 @@ it("retains the finished image when saving the project fails and retries without
it("rejects invalid bounds, seeds and missing references before queueing", () => {
const { queue, session } = setup();
- for (const input of [{ ...options(), bounds: { x: 0, y: 0, width: 128, height: 96 } }, { ...options(), seed: -2 }, { ...options(), prompt: "@[ref:missing]" }]) {
+ for (const input of [{ ...options(), bounds: { x: 128, y: 0, width: 128, height: 96 } }, { ...options(), seed: -2 }, { ...options(), prompt: "@[ref:missing]" }]) {
expect(() => queue.enqueueExtendImage(session, template, "source", input)).toThrow();
}
expect(queue.getSnapshot()).toHaveLength(0);
});
+
+
+it("submits a contained crop for real regeneration and saves the new child", async () => {
+ const { queue, session } = setup();
+ const bounds = { x: 32, y: 32, width: 64, height: 64 };
+ queue.enqueueExtendImage(session, template, "source", { ...options(), bounds, prompt: "" });
+ const request = await submitted();
+ expect(request).toMatchObject({ canvasWidth: 768, canvasHeight: 768, referencePaths: [`C:/Extend/cache/extend-images/${request.jobId}/canvas.png`],
+ imageEdit: { edits: [{ x: 0, y: 0, width: 768, height: 768, strength: 0.65, invertMask: false, feather: 0 }] } });
+ expect(request.prompt).toContain("<Picture 1>");
+ expect(invoke).toHaveBeenCalledWith("prepare_extend_image", { folderPath: "C:/Extend", jobId: request.jobId, sourceId: "source", bounds, output: { width: 768, height: 768 } });
+ expect(session.getSnapshot().config.assets.at(-1)!.name).toBe("Regenerated - source");
+ emit("framesReady", request.jobId);
+ await waitFor(() => expect(queue.getSnapshot()[0].status).toBe("completed"));
+ expect(session.getSnapshot().config.assets.at(-1)).toMatchObject({ name: "Regenerated - source", imageDraft: false, imageGeneration: { template: { kind: "extend", bounds } } });
+ expect(invoke).toHaveBeenCalledWith("save_extended_image", { folderPath: "C:/Extend", jobId: request.jobId });
+});
diff --git a/src/lib/imageEditing.ts b/src/lib/imageEditing.ts
index a7aa385..d98fa55 100644
--- a/src/lib/imageEditing.ts
+++ b/src/lib/imageEditing.ts
@@ -6,6 +6,8 @@ import type { ProjectConfig, ProjectReference } from "./project";
export interface ImageEditStep {
prompt: string; x: number; y: number; width: number; height: number;
feather?: number;
+ /** Denoising strength; lower values retain more of the source detail. */
+ strength?: number;
/** Preserve this box and generate its surround in a single outpainting pass. */
invertMask?: boolean;
referencePaths?: string[];
diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.ts
index 24fbfc4..7e9ab9b 100644
--- a/src/lib/workQueue.ts
+++ b/src/lib/workQueue.ts
@@ -316,10 +316,12 @@ export class WorkQueue {
const id = `extend-${crypto.randomUUID()}`;
const sourceRelativePath = `cache/extend-images/${id}/canvas.png`;
const compiled = compileExtendImage(config, source, sourceRelativePath, options);
- // The inpainting canvas already supplies the original at its selected size
- // and position. A separate reference is resized independently by the model
- // and can reproduce the whole original scene inside the extension.
+ // Outpainting uses the positioned canvas as context. Crop regeneration
+ // also supplies the prepared crop as its composition reference.
const referencePaths = compiled.references.flatMap((reference) => referenceImages(reference).map((image) => projectItemPath(session.record.folderPath, image)!));
+ const regenerate = compiled.layout.mode === "regenerate";
+ if (regenerate) referencePaths.unshift(projectItemPath(session.record.folderPath, { relativePath: sourceRelativePath })!);
+ const resultName = `${regenerate ? "Regenerated" : "Extended"} - ${source.name}`;
const request: SlopfabGenerationRequest = { jobId: id, stillImage: true, frames: 1, prompt: compiled.prompt,
canvasWidth: compiled.layout.output.width, canvasHeight: compiled.layout.output.height, steps: generationStepsWithLoras(options.steps, config), seed: imageGenerationSeed(options.seed),
referencePaths, refmods: referenceRefmodInputs(session.record.folderPath, compiled.references),
@@ -331,14 +333,14 @@ export class WorkQueue {
usedSeed: request.seed,
template: { kind: "extend", sourceId, sourceName: source.name, generatorName: template.name, ...structuredClone(options), steps: request.steps },
};
- this.work.set(id, { id, image: true, imageDraftId: id, extend: { sourceId, name: `Extended - ${source.name}`, options: structuredClone(options) }, imageParentId: sourceId,
+ this.work.set(id, { id, image: true, imageDraftId: id, extend: { sourceId, name: resultName, options: structuredClone(options) }, imageParentId: sourceId,
imageGeneration,
session, sceneId: current.imageScene?.nodes[0].id ?? "image-root", config, snapshot: JSON.stringify(current.imageScene), request, submitted: false, cancelled: false, done, finish });
this.items = [...this.items, { id, kind: "image", imageAssetId: sourceId, imageDraftId: id, projectKey, folderPath: session.record.folderPath, projectName: config.name,
- sceneId: this.work.get(id)!.sceneId, title: `Extend · ${source.name}`, submittedAt: new Date().toISOString(), status: "queued", progress: 0,
- detail: "Waiting to extend image", error: null, completionAt: null, cancelling: false, needsSave: false,
+ sceneId: this.work.get(id)!.sceneId, title: `${regenerate ? "Regenerate" : "Extend"} · ${source.name}`, submittedAt: new Date().toISOString(), status: "queued", progress: 0,
+ detail: regenerate ? "Waiting to regenerate selection" : "Waiting to extend image", error: null, completionAt: null, cancelling: false, needsSave: false,
settings: { frames: 1, steps: request.steps, seed: request.seed, canvasWidth: request.canvasWidth, canvasHeight: request.canvasHeight } }];
- session.update((current) => createTemplateImageDraft(current, id, `Extended - ${source.name}`, imageGeneration, compiled.layout.output));
+ session.update((current) => createTemplateImageDraft(current, id, resultName, imageGeneration, compiled.layout.output));
this.publish(); this.icons.yieldToVideo(); void this.pump();
}
enqueueCharacterSheet(session: ProjectSession, template: GeneratorTemplate, sourceId: string, options?: CharacterSheetOptions) {