Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(ui): scale canvas generations automatically by default

Josh Corbettc09afb836227
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/canvasScaling.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/canvasScaling.test.ts
index 86d555fdd9..07e4680c9c 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/canvasScaling.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/canvasScaling.test.ts
@@ -3,15 +3,19 @@ import { describe, expect, it } from 'vitest';
import { readCanvasScaling } from './canvasScaling';
describe('readCanvasScaling', () => {
- it('defaults to no scaling with no manual size', () => {
- expect(readCanvasScaling(undefined)).toEqual({ height: null, method: 'none', width: null });
+ it('defaults to auto scaling with no manual size', () => {
+ expect(readCanvasScaling(undefined)).toEqual({ height: null, method: 'auto', width: null });
expect(readCanvasScaling({ scaleMethod: 'bigger', scaledWidth: -5, scaledHeight: 'tall' })).toEqual({
height: null,
- method: 'none',
+ method: 'auto',
width: null,
});
});
+ it('keeps an explicit choice of no scaling', () => {
+ expect(readCanvasScaling({ scaleMethod: 'none' }).method).toBe('none');
+ });
+
it('reads a persisted manual size as whole pixels', () => {
expect(readCanvasScaling({ scaleMethod: 'manual', scaledWidth: 768.4, scaledHeight: 512 })).toEqual({
height: 512,
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/canvasScaling.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/canvasScaling.ts
index 961f9f1b43..9990151aa3 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/canvasScaling.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/canvasScaling.ts
@@ -10,8 +10,8 @@ export const CANVAS_SCALING_KEYS = {
export const CANVAS_SCALE_METHODS: readonly CanvasScaleMethod[] = ['none', 'auto', 'manual'];
-/** No scaling: the bbox is processed as-is (snapped to the model grid). */
-export const DEFAULT_CANVAS_SCALING: CanvasScalingSettings = { height: null, method: 'none', width: null };
+/** Auto: a small bbox grows to the model's optimal area, so canvases that never chose a method still process well. */
+export const DEFAULT_CANVAS_SCALING: CanvasScalingSettings = { height: null, method: 'auto', width: null };
const isScaleMethod = (value: unknown): value is CanvasScaleMethod =>
CANVAS_SCALE_METHODS.includes(value as CanvasScaleMethod);
@@ -23,7 +23,7 @@ export const readCanvasScaling = (values: Record<string, unknown> | undefined):
const method = values?.[CANVAS_SCALING_KEYS.method];
return {
height: readSide(values?.[CANVAS_SCALING_KEYS.height]),
- method: isScaleMethod(method) ? method : 'none',
+ method: isScaleMethod(method) ? method : DEFAULT_CANVAS_SCALING.method,
width: readSide(values?.[CANVAS_SCALING_KEYS.width]),
};
};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts
index 67687518d4..00dfff39f1 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts
@@ -262,7 +262,8 @@ const makeHarness = (options: HarnessOptions = {}): Harness => {
outputOnlyMaskedRegions: options.outputOnlyMaskedRegions ?? true,
},
destination: options.destination ?? 'canvas',
- scaling: options.scaling ?? DEFAULT_CANVAS_SCALING,
+ // The harness's tiny frames would grow under the default auto scaling; wiring tests read them at frame size.
+ scaling: options.scaling ?? { ...DEFAULT_CANVAS_SCALING, method: 'none' },
commands: {
generation: {
submitCanvas: (payload) => dispatch({ ...payload, type: 'submitCanvasInvocationSnapshot' }),