Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat(create): a Qwen-Image 2.1 edit can come out in a shape of its own (C75)

purple838cdb1c5e7b
diff --git a/e2e/n2-create-310.spec.ts b/e2e/n2-create-310.spec.ts
new file mode 100644
index 00000000..8792d6d3
--- /dev/null
+++ b/e2e/n2-create-310.spec.ts
@@ -0,0 +1,225 @@
+import { test, expect, type Page } from '@playwright/test'
+import { writeFileSync } from 'fs'
+import { tauriMockInit, DEFAULT_ASSISTANT_REPLY, DEFAULT_MODEL_NAME } from './support/tauri-mock'
+import { seedOnboardingDone } from './support/cloud-mock'
+import { gradientPng } from './support/png'
+import { appModules, type AppWindow } from './support/ui'
+
+/**
+ * N2 for 3.1.0 on a Windows or Linux desktop with a stand-in ComfyUI that
+ * lists the Qwen-Image 2.1 nodes and records every graph posted to /prompt:
+ *
+ * C75 a Qwen-Image 2.1 edit in a shape of its own ("Custom size")
+ * C72 a workflow of the user's own takes the LoRA stack, and one whose
+ * loader does not fit the model says so before and after the run
+ * C79 the LoRA list under Workflow parameters has a search and is LU's
+ * own list, readable in LU Dark
+ *
+ * LU_SHOTS=<folder> writes the screenshots and the posted graphs there.
+ */
+
+const QWEN = 'qwen_image_2.1_int8_convrot.safetensors'
+const SHOTS = process.env.LU_SHOTS
+const PNG = gradientPng(768, 512).toString('base64')
+const LORAS = ['detail_slider.safetensors', ...Array.from({ length: 30 }, (_, i) => `style_${String(i).padStart(2, '0')}.safetensors`)]
+
+type Graph = Record<string, { class_type: string; inputs: Record<string, unknown>; _meta?: { title?: string } }>
+
+async function boot(page: Page) {
+ await page.addInitScript(tauriMockInit, { assistantReply: DEFAULT_ASSISTANT_REPLY, modelName: DEFAULT_MODEL_NAME, platform: 'windows' as const })
+ await seedOnboardingDone(page)
+ await page.addInitScript(({ model, loras }) => {
+ const w = window as unknown as { __PROMPTS__: string[]; __TAURI_INTERNALS__: { invoke: (c: string, a: { url?: string; method?: string; body?: string }) => Promise<unknown> } }
+ if (!localStorage.getItem('create-store')) {
+ localStorage.setItem('create-store', JSON.stringify({ state: { backend: 'local', imageModel: model }, version: 2 }))
+ }
+ w.__PROMPTS__ = []
+ const bridge = w.__TAURI_INTERNALS__
+ const invoke = bridge.invoke
+ const combo = (v: string[]) => [v]
+ const nodes: Record<string, unknown> = {
+ UNETLoader: { input: { required: { unet_name: combo([model]), weight_dtype: combo(['default', 'fp8_e4m3fn']) } } },
+ CheckpointLoaderSimple: { input: { required: { ckpt_name: combo(['juggernaut.safetensors']) } } },
+ CLIPLoader: { input: { required: { clip_name: combo(['qwen3vl_8b_int8_convrot.safetensors']), type: combo(['qwen_image', 'stable_diffusion']), device: combo(['default', 'cpu']) } } },
+ VAELoader: { input: { required: { vae_name: combo(['qwen_image_2.1_vae_bf16.safetensors']) } } },
+ LoraLoader: { input: { required: { model: ['MODEL'], clip: ['CLIP'], lora_name: combo(loras), strength_model: ['FLOAT', { default: 1, min: -100, max: 100, step: 0.01 }], strength_clip: ['FLOAT', { default: 1, min: -100, max: 100, step: 0.01 }] } } },
+ LoraLoaderModelOnly: { input: { required: { model: ['MODEL'], lora_name: combo(loras), strength_model: ['FLOAT', { default: 1 }] } } },
+ KSampler: { input: { required: { model: ['MODEL'], seed: ['INT'], steps: ['INT'], cfg: ['FLOAT'], sampler_name: combo(['euler']), scheduler: combo(['simple']), positive: ['CONDITIONING'], negative: ['CONDITIONING'], latent_image: ['LATENT'], denoise: ['FLOAT', { default: 1, min: 0, max: 1, step: 0.01 }] } } },
+ TextEncodeQwenImage21: { input: { required: { clip: ['CLIP'], prompt: ['STRING'], negative_prompt: ['STRING'], resolution: ['INT'] }, optional: { vae: ['VAE'], 'images.image_1': ['IMAGE'] } } },
+ ImageScale: { input: { required: { image: ['IMAGE'], upscale_method: combo(['nearest-exact', 'bilinear', 'area', 'bicubic', 'lanczos']), width: ['INT'], height: ['INT'], crop: combo(['disabled', 'center']) } } },
+ CLIPTextEncode: { input: { required: { text: ['STRING', { multiline: true }], clip: ['CLIP'] } } },
+ ImageScaleToTotalPixels: { input: { required: {} } },
+ EmptyLatentImage: { input: { required: { width: ['INT'], height: ['INT'], batch_size: ['INT'] } } },
+ VAEEncode: { input: { required: {} } }, VAEDecode: { input: { required: { samples: ['LATENT'], vae: ['VAE'] } } },
+ SaveImage: { input: { required: { images: ['IMAGE'], filename_prefix: ['STRING'] } } }, LoadImage: { input: { required: { image: combo(['source.png']) } } },
+ }
+ bridge.invoke = (command, args) => {
+ if (command === 'sniff_model_files') return Promise.resolve([])
+ if (command !== 'proxy_localhost' || !args?.url?.includes(':8188')) return invoke(command, args)
+ const url = args.url
+ if (url.includes('/system_stats')) return Promise.resolve(JSON.stringify({ devices: [{ name: 'RTX 4090', type: 'cuda', vram_total: 24 * 1024 ** 3 }] }))
+ if (url.endsWith('/prompt') && args.method === 'POST') {
+ w.__PROMPTS__.push(String(args.body))
+ return Promise.resolve(JSON.stringify({ prompt_id: `p${w.__PROMPTS__.length}`, number: 1, node_errors: {} }))
+ }
+ const hist = /\/history\/(p\d+)/.exec(url)
+ if (hist) {
+ const images = [{ filename: `n2_${hist[1]}.png`, subfolder: '', type: 'output' }]
+ return Promise.resolve(JSON.stringify({ [hist[1]]: { status: { status_str: 'success', completed: true, messages: [] }, outputs: { '9': { images } } } }))
+ }
+ if (url.includes('/queue')) return Promise.resolve(JSON.stringify({ queue_running: [], queue_pending: [] }))
+ const one = /\/object_info\/([^/?]+)/.exec(url)
+ if (one) return Promise.resolve(JSON.stringify(one[1] in nodes ? { [one[1]]: nodes[one[1]] } : {}))
+ if (url.includes('/object_info')) return Promise.resolve(JSON.stringify(nodes))
+ return Promise.resolve('{}')
+ }
+ }, { model: QWEN, loras: LORAS })
+ await page.route(/:8188\/view/, (route) => route.fulfill({ status: 200, contentType: 'image/png', body: Buffer.from(PNG, 'base64') }))
+}
+
+const shot = async (page: Page, name: string) => {
+ if (!SHOTS) return
+ await page.waitForTimeout(600)
+ await page.screenshot({ path: `${SHOTS}/${name}.png` })
+}
+
+const posted = (page: Page) => page.evaluate(() => (window as unknown as { __PROMPTS__: string[] }).__PROMPTS__.map((p) => (JSON.parse(p) as { prompt: Graph }).prompt))
+
+const drawer = (page: Page) => page.locator('aside').filter({ hasText: 'Advanced settings' })
+
+async function openCreate(page: Page, tab: 'Image' | 'Edit / Image to Image') {
+ await boot(page)
+ await page.goto('/')
+ await page.getByRole('button', { name: /^Create$/ }).click()
+ await page.getByRole('radio', { name: tab, exact: true }).click()
+ await appModules(page, ['/src/stores/createStore.ts', '/src/stores/workflowStore.ts', '/src/api/workflows.ts'])
+}
+
+const stageSource = (page: Page) => page.evaluate((png) => {
+ const s = (window as unknown as AppWindow).__APP__['/src/stores/createStore.ts'].useCreateStore
+ s.setState({ source: { filename: 'source.png', url: `data:image/png;base64,${png}`, width: 768, height: 512 }, sourceSetAt: Date.now() })
+}, PNG)
+
+/** A workflow of the user's own, assigned to the Qwen model by name. */
+const installWorkflow = (page: Page, graph: Graph, name: string) => page.evaluate(({ graph, name, model }) => {
+ const app = (window as unknown as AppWindow).__APP__
+ const parameterMap = app['/src/api/workflows.ts'].autoDetectParameterMap(graph)
+ app['/src/stores/workflowStore.ts'].useWorkflowStore.setState({
+ installedWorkflows: [{ id: 'wf-n2', name, description: '', source: 'manual', modelTypes: ['qwenimage'], mode: 'image', workflow: graph, parameterMap, installedAt: 1 }],
+ modelNameAssignments: { [model]: 'wf-n2' }, paramOverrides: {},
+ })
+}, { graph, name, model: QWEN })
+
+const OWN_QWEN: Graph = {
+ '1': { class_type: 'UNETLoader', inputs: { unet_name: QWEN, weight_dtype: 'default' } },
+ '2': { class_type: 'LoraLoader', inputs: { model: ['1', 0], clip: ['4', 0], lora_name: 'detail_slider.safetensors', strength_model: 0.8, strength_clip: 0.8 }, _meta: { title: 'Detail LoRA' } },
+ '4': { class_type: 'CLIPLoader', inputs: { clip_name: 'qwen3vl_8b_int8_convrot.safetensors', type: 'qwen_image', device: 'default' } },
+ '5': { class_type: 'VAELoader', inputs: { vae_name: 'qwen_image_2.1_vae_bf16.safetensors' } },
+ '6': { class_type: 'CLIPTextEncode', inputs: { text: 'a cat', clip: ['2', 1] } },
+ '7': { class_type: 'CLIPTextEncode', inputs: { text: '', clip: ['2', 1] } },
+ '8': { class_type: 'EmptyLatentImage', inputs: { width: 1024, height: 1024, batch_size: 1 } },
+ '3': { class_type: 'KSampler', inputs: { model: ['2', 0], positive: ['6', 0], negative: ['7', 0], latent_image: ['8', 0], seed: 1, steps: 20, cfg: 2.5, sampler_name: 'euler', scheduler: 'simple', denoise: 1 } },
+ '10': { class_type: 'VAEDecode', inputs: { samples: ['3', 0], vae: ['5', 0] } },
+ '9': { class_type: 'SaveImage', inputs: { images: ['10', 0], filename_prefix: 'own' } },
+}
+
+const CHECKPOINT_WF: Graph = {
+ '4': { class_type: 'CheckpointLoaderSimple', inputs: { ckpt_name: 'juggernaut.safetensors' } },
+ '6': { class_type: 'CLIPTextEncode', inputs: { text: 'a cat', clip: ['4', 1] } },
+ '7': { class_type: 'CLIPTextEncode', inputs: { text: '', clip: ['4', 1] } },
+ '5': { class_type: 'EmptyLatentImage', inputs: { width: 1024, height: 1024, batch_size: 1 } },
+ '3': { class_type: 'KSampler', inputs: { model: ['4', 0], positive: ['6', 0], negative: ['7', 0], latent_image: ['5', 0], seed: 1, steps: 20, cfg: 7, sampler_name: 'euler', scheduler: 'simple', denoise: 1 } },
+ '8': { class_type: 'VAEDecode', inputs: { samples: ['3', 0], vae: ['4', 2] } },
+ '9': { class_type: 'SaveImage', inputs: { images: ['8', 0], filename_prefix: 'sdxl' } },
+}
+
+test('C75: a Qwen-Image 2.1 edit in 16:9 from a 3:2 picture crops the source to that shape before the encode', async ({ page }) => {
+ await openCreate(page, 'Edit / Image to Image')
+ await stageSource(page)
+ await page.getByRole('button', { name: 'Advanced settings' }).click()
+ const shape = drawer(page).getByTestId('qwen-edit-shape')
+ await expect(shape).toBeVisible({ timeout: 15_000 })
+ // The default is the run of today.
+ await expect(shape.getByRole('radio', { name: 'Like the picture' })).toHaveAttribute('aria-checked', 'true')
+ await expect(shape).toContainText('The edit keeps the shape of the picture')
+ await shape.getByRole('radio', { name: 'Custom size' }).click()
+ await drawer(page).getByRole('button', { name: '16:9', exact: true }).click()
+ await expect(shape).toContainText('The picture is scaled to fill that shape and cropped from its centre.')
+ await shape.scrollIntoViewIfNeeded()
+ await shot(page, 'c75-edit-seitenverhaeltnis')
+ const size = await page.evaluate(() => {
+ const s = (window as unknown as AppWindow).__APP__['/src/stores/createStore.ts'].useCreateStore.getState()
+ return { width: s.width as number, height: s.height as number }
+ })
+ expect(size.width / size.height).toBeCloseTo(16 / 9, 1)
+ await page.keyboard.press('Escape')
+
+ await page.getByRole('textbox').filter({ hasText: '' }).first().fill('make it a beach at sunset')
+ await page.getByRole('button', { name: /^Create$/ }).last().click()
+ await expect.poll(async () => (await posted(page)).length, { timeout: 20_000 }).toBe(1)
+ const graph = (await posted(page))[0]
+ const [scaleId, scale] = Object.entries(graph).find(([, n]) => n.class_type === 'ImageScale')!
+ expect(scale.inputs).toMatchObject({ width: size.width, height: size.height, crop: 'center', upscale_method: 'lanczos' })
+ expect(graph[(scale.inputs.image as [string, number])[0]].inputs.image).toBe('source.png')
+ const enc = Object.values(graph).find((n) => n.class_type === 'TextEncodeQwenImage21')!
+ expect(enc.inputs['images.image_1']).toEqual([scaleId, 0])
+ if (SHOTS) writeFileSync(`${SHOTS}/c75-workflow-16zu9.json`, JSON.stringify(graph, null, 2))
+})
+
+test('C72 + C79: an own workflow takes the LoRA stack, and its LoRA list has a search', async ({ page }) => {
+ await openCreate(page, 'Image')
+ await installWorkflow(page, OWN_QWEN, 'My Qwen with a LoRA')
+ await page.evaluate(() => {
+ const s = (window as unknown as AppWindow).__APP__['/src/stores/createStore.ts'].useCreateStore
+ s.setState({ selectedLoras: [{ name: 'style_07.safetensors', strength: 0.7 }] })
+ })
+ await page.getByRole('button', { name: 'Advanced settings' }).click()
+ const params = drawer(page).getByRole('region', { name: 'Workflow parameters' })
+ await expect(params).toBeVisible({ timeout: 15_000 })
+ await params.getByRole('button', { name: /Detail LoRA/ }).click()
+ await params.getByRole('button', { name: 'Lora name' }).click()
+ const search = page.getByRole('textbox', { name: 'Search Lora name' })
+ await expect(search).toBeVisible()
+ await search.fill('style_1')
+ await expect(page.getByRole('listbox').getByRole('option')).toHaveCount(10)
+ await shot(page, 'c79-lora-liste-mit-suche')
+ await page.getByRole('listbox').getByRole('option', { name: 'style_12.safetensors' }).click()
+ await expect(params.getByRole('button', { name: 'Lora name' })).toHaveText('style_12.safetensors')
+ await page.keyboard.press('Escape')
+
+ await page.getByRole('textbox').filter({ hasText: '' }).first().fill('a cat on a sofa')
+ await page.getByRole('button', { name: /^Create$/ }).last().click()
+ await expect.poll(async () => (await posted(page)).length, { timeout: 20_000 }).toBe(1)
+ const graph = (await posted(page))[0]
+ // The workflow's own LoRA, with the file picked in the list.
+ expect(graph['2'].inputs.lora_name).toBe('style_12.safetensors')
+ // The stack's LoRA, chained in behind the model loader.
+ const [addedId, added] = Object.entries(graph).find(([, n]) => n._meta?.title === 'LoRA (LU): style_07.safetensors')!
+ expect(added.class_type).toBe('LoraLoader')
+ expect(added.inputs).toMatchObject({ model: ['1', 0], clip: ['4', 0], strength_model: 0.7, strength_clip: 0.7 })
+ expect(graph['2'].inputs.model).toEqual([addedId, 0])
+ expect(graph['2'].inputs.clip).toEqual([addedId, 1])
+ if (SHOTS) writeFileSync(`${SHOTS}/c72-workflow-mit-lora.json`, JSON.stringify(graph, null, 2))
+})
+
+test('C72: a workflow whose loader does not fit the model says so in the settings and under the result', async ({ page }) => {
+ await openCreate(page, 'Image')
+ await installWorkflow(page, CHECKPOINT_WF, 'My SDXL workflow')
+ await page.getByRole('button', { name: 'Advanced settings' }).click()
+ const misfit = drawer(page).getByTestId('own-workflow-misfit')
+ await expect(misfit).toBeVisible({ timeout: 15_000 })
+ await expect(misfit).toContainText('Your workflow "My SDXL workflow" is not used: this model is a diffusion model and needs a UNETLoader')
+ await misfit.scrollIntoViewIfNeeded()
+ await shot(page, 'c72-hinweis-lader-passt-nicht')
+ await page.keyboard.press('Escape')
+
+ await page.getByRole('textbox').filter({ hasText: '' }).first().fill('a cat on a sofa')
+ await page.getByRole('button', { name: /^Create$/ }).last().click()
+ await expect.poll(async () => (await posted(page)).length, { timeout: 20_000 }).toBe(1)
+ // LU's own graph ran, and the result says why.
+ const graph = (await posted(page))[0]
+ expect(Object.values(graph).some((n) => n.class_type === 'TextEncodeQwenImage21')).toBe(true)
+ expect(Object.values(graph).some((n) => n.class_type === 'CheckpointLoaderSimple')).toBe(false)
+ await expect(page.getByTestId('run-note')).toContainText('is not used', { timeout: 20_000 })
+ await shot(page, 'c72-hinweis-am-ergebnis')
+})
diff --git a/src/api/__tests__/qwen-edit-shape-c75.test.ts b/src/api/__tests__/qwen-edit-shape-c75.test.ts
new file mode 100644
index 00000000..f2f8d2ab
--- /dev/null
+++ b/src/api/__tests__/qwen-edit-shape-c75.test.ts
@@ -0,0 +1,92 @@
+/**
+ * C75 (Discord feature-requests, 11.11.2026): a Qwen-Image 2.1 edit could
+ * only come out in the shape of its source. With "Custom size" it comes out
+ * in the shape of the size fields: the source is scaled to cover that shape
+ * and cropped from its centre BEFORE the encode node, whose latent follows
+ * the first image (any other latent size shifts the edit). The default stays.
+ *
+ * Run: npx vitest run src/api/__tests__/qwen-edit-shape-c75.test.ts
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+
+vi.mock('../comfyui-nodes', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('../comfyui-nodes')>()
+ return { ...actual, getAllNodeInfo: vi.fn() }
+})
+vi.mock('../backend', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('../backend')>()
+ return { ...actual, localFetch: vi.fn(), comfyuiUrl: (p: string) => `http://test${p}` }
+})
+
+import { buildDynamicWorkflow } from '../dynamic-workflow'
+import { getAllNodeInfo } from '../comfyui-nodes'
+import { localFetch } from '../backend'
+import { nodeOf } from './graph-test-support'
+import { QWEN21_OFFICIAL_MODEL as MODEL } from './qwen21-weights'
+import { editHiresBase } from '../../lib/edit-hires'
+
+const ENCODER = 'qwen3vl_8b_int8_convrot.safetensors'
+const VAE_FILE = 'qwen_image_2.1_vae_bf16.safetensors'
+const NODES = {
+ UNETLoader: { input: { required: { unet_name: [[MODEL]] } } },
+ CLIPLoader: { input: { required: { clip_name: [[ENCODER]] } } },
+ VAELoader: { input: { required: { vae_name: [[VAE_FILE]] } } },
+ TextEncodeQwenImage21: { input: { required: { clip: ['CLIP'], prompt: ['STRING'], negative_prompt: ['STRING'], resolution: ['INT'] }, optional: { vae: ['VAE'], 'images.image_1': ['IMAGE'] } } },
+ ImageScale: { input: { required: { image: ['IMAGE'], upscale_method: [['nearest-exact', 'bilinear', 'area', 'bicubic', 'lanczos']], width: ['INT'], height: ['INT'], crop: [['disabled', 'center']] } } },
+ EmptyLatentImage: { input: { required: {} } },
+ KSampler: { input: { required: {} } },
+ CLIPTextEncode: { input: { required: {} } },
+ VAEDecode: { input: { required: {} } },
+ LoadImage: { input: { required: {} } },
+ SaveImage: { input: { required: {} } },
+}
+
+const edit = (extra: Record<string, unknown> = {}) => ({
+ model: MODEL, prompt: 'make it a beach at sunset', negativePrompt: '', sampler: 'euler', scheduler: 'simple',
+ steps: 25, cfgScale: 1, width: 1664, height: 928, seed: 42, batchSize: 1,
+ inputImage: 'lu_source.png', denoise: 0.7, ...extra,
+})
+
+beforeEach(() => {
+ vi.mocked(getAllNodeInfo).mockResolvedValue(NODES as never)
+ vi.mocked(localFetch).mockResolvedValue({
+ ok: true,
+ json: async () => ({ CLIPLoader: { input: { required: { clip_name: [[ENCODER]] } } }, VAELoader: { input: { required: { vae_name: [[VAE_FILE]] } } } }),
+ } as never)
+})
+
+describe('the shape of a Qwen-Image 2.1 edit', () => {
+ it('by default the source goes in as it is, and the edit keeps its shape', async () => {
+ const wf = await buildDynamicWorkflow(edit() as never)
+ const [loadId] = nodeOf(wf, 'LoadImage')!
+ expect(nodeOf(wf, 'ImageScale')).toBeUndefined()
+ expect(nodeOf(wf, 'TextEncodeQwenImage21')![1].inputs['images.image_1']).toEqual([loadId, 0])
+ })
+
+ it('"Custom size": the source is cropped to the fields\' shape before the encode, the latent still comes from the node', async () => {
+ const wf = await buildDynamicWorkflow(edit({ editShape: 'canvas' }) as never)
+ const [loadId] = nodeOf(wf, 'LoadImage')!
+ const [scaleId, scale] = nodeOf(wf, 'ImageScale')!
+ expect(scale.inputs).toEqual({ image: [loadId, 0], upscale_method: 'lanczos', width: 1664, height: 928, crop: 'center' })
+ const [encId, enc] = nodeOf(wf, 'TextEncodeQwenImage21')!
+ expect(enc.inputs['images.image_1']).toEqual([scaleId, 0])
+ // The pixel budget of the fields, as before.
+ expect(enc.inputs.resolution).toBe(1248)
+ expect(nodeOf(wf, 'KSampler')![1].inputs.latent_image).toEqual([encId, 2])
+ expect(nodeOf(wf, 'EmptyLatentImage')).toBeUndefined()
+ })
+
+ it('only the source is cropped, references go in as they are', async () => {
+ const wf = await buildDynamicWorkflow(edit({ editShape: 'canvas', referenceImages: ['person.png'] }) as never)
+ const enc = nodeOf(wf, 'TextEncodeQwenImage21')![1]
+ const ref = enc.inputs['images.image_2'] as [string, number]
+ expect(wf[ref[0]].class_type).toBe('LoadImage')
+ expect(wf[ref[0]].inputs?.image).toBe('person.png')
+ })
+
+ it('the size the settings name follows the shape', () => {
+ const source = { width: 1000, height: 1500 }
+ expect(editHiresBase({ source, width: 1664, height: 928, modelType: 'qwenimage' })).toEqual({ width: 1024, height: 1536 })
+ expect(editHiresBase({ source, width: 1664, height: 928, modelType: 'qwenimage', editShape: 'canvas' })).toEqual({ width: 1664, height: 928 })
+ })
+})
diff --git a/src/api/comfyui.ts b/src/api/comfyui.ts
index 781983b6..a9cb965c 100644
--- a/src/api/comfyui.ts
+++ b/src/api/comfyui.ts
@@ -56,6 +56,9 @@ export interface GenerateParams {
seed: number
batchSize: number
inputImage?: string // I2I source image filename (uploaded to ComfyUI)
+ /** C75: a Qwen-Image 2.1 edit in the shape of width x height instead of
+ * the source's. Absent or 'source': the source's shape, as before. */
+ editShape?: 'source' | 'canvas'
/** Edit: further reference images (ComfyUI upload names) after the source,
* for the families lib/edit-references names. GH #144. */
referenceImages?: string[]
diff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.ts
index 8ad23390..b3ec5801 100644
--- a/src/api/dynamic-workflow.ts
+++ b/src/api/dynamic-workflow.ts
@@ -1266,7 +1266,28 @@ export async function buildDynamicWorkflow(
for (const [i, image] of images.entries()) {
const loadId = String(n++)
workflow[loadId] = { class_type: 'LoadImage', inputs: { image } }
- qwenInputs[`images.image_${i + 1}`] = [loadId, 0]
+ let imageRef: [string, number] = [loadId, 0]
+ if (i === 0 && gp.editShape === 'canvas') {
+ // C75 (Discord feature-requests 11.11.2026): an edit in a shape of
+ // its own. The node's latent follows the first image and has to
+ // (any other latent size shifts the edit), so the source itself is
+ // brought to the shape first: scaled to cover width x height and
+ // cropped from its centre. The pixel budget below stays the size.
+ const scaleId = String(n++)
+ workflow[scaleId] = {
+ class_type: 'ImageScale',
+ inputs: {
+ image: [loadId, 0],
+ upscale_method: resizeMethod(allNodes, 'ImageScale', false),
+ width: params.width,
+ height: params.height,
+ crop: 'center',
+ },
+ _meta: { title: 'Edit shape' },
+ }
+ imageRef = [scaleId, 0]
+ }
+ qwenInputs[`images.image_${i + 1}`] = imageRef
}
qwenInputs.vae = [vaeSourceId, vaeOutputSlot]
} else if (createRefs.length > 0) {
diff --git a/src/components/create/experimental/ParamGroups.tsx b/src/components/create/experimental/ParamGroups.tsx
index 258f6b20..efab3ae7 100644
--- a/src/components/create/experimental/ParamGroups.tsx
+++ b/src/components/create/experimental/ParamGroups.tsx
@@ -194,12 +194,18 @@ export function ParamGroups() {
// In Edit the picture comes out in the shape of the source, not of the
// sliders (lib/edit-hires). Without a source there is nothing to name yet.
const hiresBase = isEdit && !macHires
- ? editHiresBase({ source: s.source, width: s.width, height: s.height, modelType: laneType, modelName: laneModel })
+ ? editHiresBase({ source: s.source, width: s.width, height: s.height, modelType: laneType, modelName: laneModel, editShape: s.qwenEditShape })
: isEdit && macHires
// The Mac's edit comes back in the shape of the source, on the canvas
// the engine runs (1056 where the sliders say 1024, lib/image-engines).
? (s.source ? editCanvas(macEditSide(qwenEditResolution(s.width, s.height)), s.source) : null)
: { width: s.width, height: s.height }
+ // C75: a local Qwen-Image 2.1 edit on ComfyUI picks its shape. The Mac's
+ // engine edits in the shape of the source and has no such switch.
+ const qwenEditShapeShown = isEdit && !isCloud && !isMlxLocal && laneType === 'qwenimage' && showSize
+ const qwenEditOut = qwenEditShapeShown
+ ? editHiresBase({ source: s.source, width: s.width, height: s.height, modelType: 'qwenimage', editShape: s.qwenEditShape })
+ : null
// The grid a typed width or height is rounded to: the local model's latent
// cell. The cloud keeps the 64 its providers were checked against.
const sizeGrid = isCloud ? 64 : latentDownscale(laneType)
@@ -272,6 +278,35 @@ export function ParamGroups() {
)}
{/* B50: far above what the model takes, a note with the range that works. It never blocks. */}
{showCfg && !isVideo && cfgNote && <p className={`t-micro ${HINWEIS_TEXT.ruhig}`} data-testid="cfg-hint">{cfgNote}</p>}
+ {qwenEditShapeShown && (
+ // C75: the shape of a Qwen-Image 2.1 edit. The default is the one
+ // it always had; 'Custom' crops the picture to the size below.
+ <div className="space-y-1" data-testid="qwen-edit-shape">
+ <span className="t-control text-gray-400">Output shape</span>
+ <div role="radiogroup" aria-label="Output shape" className="grid grid-cols-2 gap-1">
+ {([['source', 'Like the picture'], ['canvas', 'Custom size']] as const).map(([value, text]) => (
+ <button
+ key={value}
+ type="button"
+ role="radio"
+ aria-checked={s.qwenEditShape === value}
+ onClick={() => s.setQwenEditShape(value)}
+ className={cn(
+ 'px-2 py-1 rounded border t-control transition-colors',
+ s.qwenEditShape === value
+ ? 'border-white/20 bg-white/[0.08] text-gray-200'
+ : 'border-white/[0.08] text-gray-400 hover:text-gray-200 hover:bg-white/[0.06]',
+ )}
+ >{text}</button>
+ ))}
+ </div>
+ <p className="t-micro text-gray-500">
+ {s.qwenEditShape === 'canvas'
+ ? `The edit comes out ${qwenEditOut?.width ?? s.width}×${qwenEditOut?.height ?? s.height} px. The picture is scaled to fill that shape and cropped from its centre.`
+ : `The edit keeps the shape of the picture${qwenEditOut ? `, at ${qwenEditOut.width}×${qwenEditOut.height} px` : ''}. The size below sets how many pixels.`}
+ </p>
+ </div>
+ )}
{showSize && (macSize && macClip ? (
// The Mac: the model's grid and bounds. What runs is said below.
<div className="grid grid-cols-2 gap-2">
diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.ts
index c9bca81d..3e9f5bb3 100644
--- a/src/hooks/useCreate.ts
+++ b/src/hooks/useCreate.ts
@@ -1861,6 +1861,9 @@ export function useCreate() {
// B46: a Qwen edit reads its own Edit strength (1 = as before); the
// builder ignores it on every other family.
...(isI2I && !isRemoveBg && effInputImage && state.editStrength < 1 ? { editStrength: state.editStrength } : {}),
+ // C75: a Qwen-Image 2.1 edit in the shape of the size fields. Only
+ // the edit graph of that model reads it (dynamic-workflow.ts).
+ ...(isI2I && !isRemoveBg && effInputImage && imageModelType === 'qwenimage' && state.qwenEditShape === 'canvas' ? { editShape: 'canvas' as const } : {}),
// GH #144: further references ride along; the builder keeps only as
// many as the model's family takes (lib/edit-references).
...(isI2I && !isRemoveBg && effInputImage && references.some((r) => r.filename)
@@ -2132,7 +2135,7 @@ export function useCreate() {
if (hiresFixEnabled && (intent === 'image' || hiresEdit)) {
setProgress(8, 'Adding native HiRes Fix...')
const editBase = hiresEdit
- ? editHiresBase({ source, width, height, modelType: imageModelType, modelName: activeModel })
+ ? editHiresBase({ source, width, height, modelType: imageModelType, modelName: activeModel, editShape: state.qwenEditShape })
: null
const hires = applyNativeHiresFix(workflow, {
baseWidth: editBase?.width ?? width,
diff --git a/src/lib/edit-hires.ts b/src/lib/edit-hires.ts
index 20fdf53d..fb2f0300 100644
--- a/src/lib/edit-hires.ts
+++ b/src/lib/edit-hires.ts
@@ -22,10 +22,15 @@ export function editHiresBase(opts: {
height: number
modelType?: string
modelName?: string
+ /** C75: a Qwen-Image 2.1 edit in the shape of the size fields. */
+ editShape?: 'source' | 'canvas'
}): { width: number; height: number } | null {
const { source, width, height, modelType, modelName } = opts
if (!source || !(source.width > 0) || !(source.height > 0)) return null
- if (modelType === 'qwenimage') return editCanvas(qwenEditResolution(width, height), source)
+ if (modelType === 'qwenimage') {
+ // The source is cropped to the fields' shape first, so the canvas takes it.
+ return editCanvas(qwenEditResolution(width, height), opts.editShape === 'canvas' ? { width, height } : source)
+ }
if (modelType === 'qwenimage1' && modelName && isQwenImageEditModel(modelName)) return editCanvas(1024, source)
return { width: source.width, height: source.height }
}
diff --git a/src/stores/createStore.ts b/src/stores/createStore.ts
index 22a2560c..46309dac 100644
--- a/src/stores/createStore.ts
+++ b/src/stores/createStore.ts
@@ -191,6 +191,9 @@ export type VideoBackendKind = 'comfy' | 'mlx'
// ─── Optimal defaults per model type (research-backed: Draw Things, Fooocus, ComfyUI) ───
+/** C75: see `qwenEditShape`. */
+export type QwenEditShape = 'source' | 'canvas'
+
export const MODEL_TYPE_DEFAULTS: Record<ModelType, {
steps: number; cfgScale: number; sampler: string; scheduler: string
width: number; height: number; frames?: number; fps?: number
@@ -404,6 +407,11 @@ export interface CreateState {
* `denoise`: that one starts at 0.7 for the Windows graph, and the Mac's
* edits ran at 1 until now. */
editStrength: number
+ /** C75: the shape a local Qwen-Image 2.1 edit (ComfyUI) comes out in.
+ * 'source', the default: the shape of the picture, at the pixel budget of
+ * the size fields. 'canvas': the width and height set below; the picture
+ * is scaled and cropped from its centre to that shape before the encode. */
+ qwenEditShape: QwenEditShape
/** Native text-to-image latent upscale + refinement pass (local ComfyUI). */
hiresFixEnabled: boolean
hiresScale: number
@@ -671,6 +679,7 @@ export interface CreateState {
setCloudFps: (fps: number) => void
setDenoise: (denoise: number) => void
setEditStrength: (strength: number) => void
+ setQwenEditShape: (shape: QwenEditShape) => void
setHiresFixEnabled: (enabled: boolean) => void
setHiresScale: (scale: number) => void
setHiresDenoise: (denoise: number) => void
@@ -1177,6 +1186,7 @@ export const useCreateStore = create<CreateState>()(
imageLaneKept: null,
denoise: 0.7,
editStrength: 1,
+ qwenEditShape: 'source' as QwenEditShape,
hiresFixEnabled: false,
hiresScale: 1.5,
hiresDenoise: 0.5,
@@ -1344,6 +1354,7 @@ export const useCreateStore = create<CreateState>()(
setCloudFrames: (frames) => set({ cloudFrames: Math.max(1, Math.min(3600, Math.floor(frames))) }),
setCloudFps: (fps) => set({ cloudFps: Math.max(1, Math.min(60, Math.floor(fps))) }),
setDenoise: (denoise) => set({ denoise: Math.max(0, Math.min(1, denoise)) }),
+ setQwenEditShape: (qwenEditShape) => set({ qwenEditShape: qwenEditShape === 'canvas' ? 'canvas' : 'source' }),
setEditStrength: (strength) => set({ editStrength: Number.isFinite(strength) ? Math.max(0.05, Math.min(1, strength)) : 1 }),
setHiresFixEnabled: (hiresFixEnabled) => set({ hiresFixEnabled }),
setHiresScale: (hiresScale) => set({
@@ -2047,6 +2058,7 @@ export const useCreateStore = create<CreateState>()(
...restartSampling(state),
denoise: state.denoise,
editStrength: state.editStrength,
+ qwenEditShape: state.qwenEditShape,
hiresFixEnabled: state.hiresFixEnabled,
hiresScale: state.hiresScale,
hiresDenoise: state.hiresDenoise,
@@ -2161,6 +2173,8 @@ export const useCreateStore = create<CreateState>()(
// 3.0.9 P8: same for the mode, it picks the LoRA's file name.
if ('trainKind' in safe && !isTrainKind(safe.trainKind)) safe.trainKind = TRAIN_KIND_DEFAULT
if ('trainStyleTrigger' in safe && typeof safe.trainStyleTrigger !== 'boolean') safe.trainStyleTrigger = true
+ // 3.1.0 C75: anything but the one other shape is the source's.
+ if ('qwenEditShape' in safe && safe.qwenEditShape !== 'canvas') safe.qwenEditShape = 'source'
// The persisted slice is ~30 independent scalar preferences (see
// partialize). They are adopted as written, which is what the store
// has always done; the fields that could actually do damage — the