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.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
feat(create): Transparent background for local Qwen-Image 2.1
purpleb90f94661235
diff --git a/src/api/__tests__/qwen-image-21-transparent.test.ts b/src/api/__tests__/qwen-image-21-transparent.test.tsnew file mode 100644index 00000000..dd28bd65--- /dev/null+++ b/src/api/__tests__/qwen-image-21-transparent.test.ts@@ -0,0 +1,123 @@+/**+ * Qwen-Image 2.1 "Transparent background" (02.10.2026): the workflow graph.+ *+ * Read off the real sources, not guessed:+ * - Comfy-Org/workflow_templates image_qwen_image_2_1_t2i.json, note+ * "Transparent Image": wrap the prompt, save as PNG to keep alpha.+ * - ComfyUI 0.38 comfy/sd.py: the 2.1 VAE (4 output channels) makes VAEDecode+ * return RGBA. nodes.py SaveImage writes the 4 channel array as RGBA PNG.+ * So the graph is the one that already runs; only the prompt changes. These+ * tests build the real graph against a mocked /object_info.+ *+ * Run: npx vitest run src/api/__tests__/qwen-image-21-transparent.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 { transparentPrompt } from '../../lib/transparent-image'+import { nodeOf, nodesOf } from './graph-test-support'++const MODEL = 'qwen_image_2.1_int8_convrot.safetensors'+const ENCODER = 'qwen3vl_8b_int8_convrot.safetensors'+const VAE_FILE = 'qwen_image_2.1_vae_bf16.safetensors'++const QWEN_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'] } } },+ EmptyLatentImage: { input: { required: {} } },+ KSampler: { input: { required: {} } },+ CLIPTextEncode: { input: { required: {} } },+ VAEDecode: { input: { required: {} } },+ LoadImage: { input: { required: {} } },+ SaveImage: { input: { required: {} } },+}++const baseParams = {+ model: MODEL,+ prompt: 'a red apple on a white plate', negativePrompt: '',+ sampler: 'euler', scheduler: 'simple',+ steps: 25, cfgScale: 1, width: 1024, height: 1024, seed: 42, batchSize: 1,+}++beforeEach(() => {+ vi.mocked(getAllNodeInfo).mockResolvedValue(QWEN_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('Transparent background: the graph', () => {+ it('wraps the prompt the way the official template says', async () => {+ const wf = await buildDynamicWorkflow({ ...baseParams, transparent: true } as never)+ const enc = nodesOf(wf, 'TextEncodeQwenImage21')+ expect(enc).toHaveLength(1)+ expect(enc[0][1].inputs.prompt).toBe(+ 'This is an RGBA format image with transparency. a red apple on a white plate. The image has an alpha channel and a transparent background.',+ )+ expect(enc[0][1].inputs.prompt).toBe(transparentPrompt(baseParams.prompt))+ })++ it('without the switch the prompt goes through untouched', async () => {+ const off = await buildDynamicWorkflow({ ...baseParams } as never)+ const explicit = await buildDynamicWorkflow({ ...baseParams, transparent: false } as never)+ expect(nodeOf(off, 'TextEncodeQwenImage21')![1].inputs.prompt).toBe(baseParams.prompt)+ expect(explicit).toEqual(off)+ })++ it('changes nothing else: the graph is the one that already runs', async () => {+ const plain = await buildDynamicWorkflow({ ...baseParams } as never)+ const alpha = await buildDynamicWorkflow({ ...baseParams, transparent: true } as never)+ const strip = (wf: typeof plain) => JSON.parse(JSON.stringify(wf, (k, v) => (k === 'prompt' && typeof v === 'string' ? '<prompt>' : v)))+ expect(strip(alpha)).toEqual(strip(plain))+ })++ it('decodes with the 2.1 VAE and saves straight from the decode, no node in between that could drop alpha', async () => {+ const wf = await buildDynamicWorkflow({ ...baseParams, transparent: true } as never)+ const [vaeId] = nodeOf(wf, 'VAELoader')!+ const [decodeId, decode] = nodeOf(wf, 'VAEDecode')!+ expect(decode.inputs.vae).toEqual([vaeId, 0])+ expect(nodeOf(wf, 'VAELoader')![1].inputs.vae_name).toBe(VAE_FILE)+ const saves = nodesOf(wf, 'SaveImage')+ expect(saves).toHaveLength(1)+ expect(saves[0][1].inputs.images).toEqual([decodeId, 0])+ // The classes that would flatten to three channels or re-encode as JPEG.+ const classes = Object.values(wf).map((n) => n.class_type)+ for (const bad of ['ImageScale', 'ImageScaleBy', 'ImageBlend', 'ImageCompositeMasked', 'PreviewImage', 'SaveAnimatedWEBP', 'SaveImageWebsocket']) {+ expect(classes).not.toContain(bad)+ }+ })++ it('keeps the canvas, sampler and negative prompt', async () => {+ const wf = await buildDynamicWorkflow({ ...baseParams, transparent: true, width: 1536, height: 864 } as never)+ expect(nodeOf(wf, 'EmptyLatentImage')![1].inputs).toMatchObject({ width: 1536, height: 864 })+ expect(nodeOf(wf, 'TextEncodeQwenImage21')![1].inputs.negative_prompt).toBe('')+ expect(nodeOf(wf, 'KSampler')![1].inputs.cfg).toBe(1)+ })++ it('an edit takes its picture from the reference: the wrapper stays out of it', async () => {+ const wf = await buildDynamicWorkflow({ ...baseParams, prompt: 'make the apple green', transparent: true, inputImage: 'lu_source.png', denoise: 0.7 } as never)+ expect(nodeOf(wf, 'TextEncodeQwenImage21')![1].inputs.prompt).toBe('make the apple green')+ })++ it('a prompt that already ends in a full stop is not wrapped into a double one', async () => {+ const wf = await buildDynamicWorkflow({ ...baseParams, prompt: 'a red apple.', transparent: true } as never)+ expect(nodeOf(wf, 'TextEncodeQwenImage21')![1].inputs.prompt).toContain('transparency. a red apple. The image has')+ })+})diff --git a/src/api/comfyui.ts b/src/api/comfyui.tsindex f5592dd4..e60c524d 100644--- a/src/api/comfyui.ts+++ b/src/api/comfyui.ts@@ -61,6 +61,9 @@ export interface GenerateParams {modelParts?: { textEncoder: boolean; vae: boolean }denoise?: number // I2I denoise strength (0.0–1.0, default 1.0 = full txt2img)removebg?: boolean // Background removal: LoadImage → RMBG → SaveImage cutout (no diffusion)+ /** Qwen-Image 2.1 text-to-image only: ask for an RGBA picture with a+ * transparent background (lib/transparent-image.ts). Ignored elsewhere. */+ transparent?: boolean// Local Edit (mask inpaint): ComfyUI /upload/image filename of the painted// mask (white = repaint). With inputImage set this selects the inpaint// pipeline (VAEEncodeForInpaint / InpaintModelConditioning) on thediff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.tsindex 1d719697..4d91856b 100644--- a/src/api/dynamic-workflow.ts+++ b/src/api/dynamic-workflow.ts@@ -1,3 +1,4 @@+import { transparentPrompt } from '../lib/transparent-image'import {classifyModel, findMatchingVAE, findMatchingCLIP, findFluxCLIPPair, findMiniMaxAudioVAE, findLtx25AudioVAE, isFastH3,findMatchingAudioEncoder, findMatchingClipVision, findFramePackCLIPPair,@@ -1097,7 +1098,11 @@ export async function buildDynamicWorkflow(// t2i template, which also carries the widget and never uses it.const qwenInputs: ComfyNodeInputs = {clip: [clipSourceId, clipOutputSlot],- prompt: params.prompt,+ // Transparent background: the model writes an alpha channel when the+ // prompt is wrapped the way the official template says, and SaveImage+ // below keeps it (lib/transparent-image.ts). An edit takes its picture+ // from the reference, so the wrapper stays out of it.+ prompt: gp.transparent && !isQwenEdit ? transparentPrompt(params.prompt) : params.prompt,negative_prompt: params.negativePrompt || '',resolution: qwenEditResolution(params.width, params.height),}diff --git a/src/components/create/experimental/CreatePanel.tsx b/src/components/create/experimental/CreatePanel.tsxindex ee8d05ee..7b949fcd 100644--- a/src/components/create/experimental/CreatePanel.tsx+++ b/src/components/create/experimental/CreatePanel.tsx@@ -1,3 +1,4 @@+import { itemHasAlpha } from '../../../lib/transparent-image'import { motion, AnimatePresence } from 'framer-motion'import { Images, Play, PanelRightClose, Trash2, Download, MonitorOff, AudioLines } from 'lucide-react'import { useCreateStore, type GalleryItem } from '../../../stores/createStore'@@ -115,7 +116,7 @@ export function CreatePanel({ open, onOpenChange, activeId, onSelect }: Props) {className={cn('w-full aspect-square rounded-lg overflow-hidden border-2 transition-colors relative',(activeId ?? gallery[0]?.id) === g.id ? 'border-white/60' : 'border-transparent hover:border-white/20',- g.intent === 'removebg' && 'lu-checker',+ itemHasAlpha(g) && 'lu-checker',)}><GalleryThumb g={g} />diff --git a/src/components/create/experimental/Lightbox.tsx b/src/components/create/experimental/Lightbox.tsxindex d6585ce0..d260de52 100644--- a/src/components/create/experimental/Lightbox.tsx+++ b/src/components/create/experimental/Lightbox.tsx@@ -1,3 +1,4 @@+import { itemHasAlpha } from '../../../lib/transparent-image'import { useEffect } from 'react'import { motion, AnimatePresence } from 'framer-motion'import { X, Sparkles } from 'lucide-react'@@ -102,7 +103,7 @@ export function Lightbox({ item, onClose }: { item: GalleryItem | null; onClose:alt={item.prompt}onError={onMediaError}onClick={(e) => e.stopPropagation()}- className={cn('max-w-full max-h-full object-contain rounded-lg', item.intent === 'removebg' && 'lu-checker')}+ className={cn('max-w-full max-h-full object-contain rounded-lg', itemHasAlpha(item) && 'lu-checker')}/>)}<PromptDetails item={item} className="absolute bottom-4 left-1/2 max-h-[40vh] -translate-x-1/2 overflow-y-auto bg-black/70" />diff --git a/src/components/create/experimental/OutputView.tsx b/src/components/create/experimental/OutputView.tsxindex 3cd98b65..7c2dbf63 100644--- a/src/components/create/experimental/OutputView.tsx+++ b/src/components/create/experimental/OutputView.tsx@@ -1,3 +1,4 @@+import { itemHasAlpha } from '../../../lib/transparent-image'import { useEffect, useState } from 'react'import { motion } from 'framer-motion'import { Cpu, Sparkles, ImageDown, Maximize2, Download, Wand2, MonitorOff, AudioLines, Film, Trash2 } from 'lucide-react'@@ -170,7 +171,7 @@ export function ResultView({ item, onFullscreen, onSendToEditor, onAnimate }: Realt={item.prompt}onError={onError}onLoad={(e) => { markGalleryItemAvailable(item); reconcileDims(item, e.currentTarget.naturalWidth, e.currentTarget.naturalHeight) }}- className={cn('max-w-full max-h-[62vh] object-contain rounded-[var(--radius-panel)] border border-white/[0.06]', item.intent === 'removebg' && 'lu-checker')}+ className={cn('max-w-full max-h-[62vh] object-contain rounded-[var(--radius-panel)] border border-white/[0.06]', itemHasAlpha(item) && 'lu-checker')}/>)}{item.unavailable && (diff --git a/src/components/create/experimental/ParamGroups.tsx b/src/components/create/experimental/ParamGroups.tsxindex 58df40e3..ad4b2eec 100644--- a/src/components/create/experimental/ParamGroups.tsx+++ b/src/components/create/experimental/ParamGroups.tsx@@ -18,6 +18,7 @@ import { Tooltip } from '../ui/Tooltip'import { cn } from '../ui/cn'import { HINWEIS_TEXT } from '../../../lib/hinweis'import { lorasForRun, loraFitsModel } from '../../../lib/lora-stack'+import { supportsTransparent } from '../../../lib/transparent-image'// Video families whose dynamic-workflow strategy actually wires a LoRA node:// the generic UNET path (wan/hunyuan/ltx/mochi/cosmos) plus Wan 2.2's dedicated@@ -86,6 +87,10 @@ export function ParamGroups() {}}+ // Transparent background: local Qwen-Image 2.1 text-to-image only, the one+ // model family whose VAE writes an alpha channel (lib/transparent-image.ts).+ const showTransparent = !isCloud && !isVideo && meta.id === 'image' && !isMlxLocal && supportsTransparent(laneType)+const samplers = samplerList.length ? samplerList : SAMPLERS_FALLBACKconst schedulers = schedulerList.length ? schedulerList : SCHEDULERS_FALLBACKconst vaes = vaeList.length ? vaeList : ['auto']@@ -204,6 +209,26 @@ export function ParamGroups() {{/* Cloud: Bilder pro Lauf, jedes ein eigener Auftrag mit eigenem Preis.Lokal bleibt es die Batch size der ComfyUI-Warteschlange. */}{isCloud && imageCountApplies(meta.id) && <Slider label="Images" min={1} max={MAX_IMAGE_COUNT} step={1} value={s.cloudImageCount} onChange={s.setCloudImageCount} />}+ {showTransparent && (+ <button+ type="button"+ role="switch"+ aria-checked={s.transparentBackground}+ onClick={() => s.setTransparentBackground(!s.transparentBackground)}+ className={cn(+ 'flex w-full items-center justify-between rounded-lg border px-3 py-2 text-left transition-colors',+ s.transparentBackground ? 'border-white/15 bg-white/[0.05]' : 'border-white/[0.07]',+ )}+ >+ <span>+ <span className="block t-control text-gray-300">Transparent background</span>+ <span className="block text-[11px] leading-4 text-gray-600">Saves a PNG with a see-through background</span>+ </span>+ <span className={cn('t-mono text-xs', s.transparentBackground ? 'text-emerald-400' : 'text-gray-600')}>+ {s.transparentBackground ? 'on' : 'off'}+ </span>+ </button>+ )}{!isVideo && !isCloud && <Slider label="Batch size" min={1} max={8} step={1} value={s.batchSize} onChange={s.setBatchSize} />}{isVideo && (<div className="grid grid-cols-2 gap-2">diff --git a/src/components/create/experimental/__tests__/transparent-background-oberflaeche.test.tsx b/src/components/create/experimental/__tests__/transparent-background-oberflaeche.test.tsxnew file mode 100644index 00000000..4598627f--- /dev/null+++ b/src/components/create/experimental/__tests__/transparent-background-oberflaeche.test.tsx@@ -0,0 +1,109 @@+// @vitest-environment jsdom+/**+ * "Transparent background" (02.10.2026): der Schalter in den Bild-Einstellungen,+ * nur fuer lokales Qwen-Image 2.1, und das Karomuster fuer das Ergebnis.+ */+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { cleanup, fireEvent, render, screen } from '@testing-library/react'++const host = vi.hoisted(() => ({ mlx: false }))+vi.mock('../../../../api/mlx-image', () => ({ isMlxImageHost: () => host.mlx }))+vi.mock('../../../../api/comfyui', () => ({+ classifyModel: (n: string) => (/qwen_image_2\.1/.test(n) ? 'qwenimage' : 'sdxl'),+ isI2VModel: () => false,+ isT2VCapable: () => true,+ getImageUrl: (f: string) => `http://127.0.0.1:8188/view?filename=${f}`,+}))+vi.mock('../CreateContext', () => ({+ useCreateExp: () => ({+ samplerList: [], schedulerList: [], loraList: [], vaeList: [], refreshModelLists: vi.fn(),+ }),+}))++import { ParamGroups } from '../ParamGroups'+import { ResultView } from '../OutputView'+import { useCreateStore, type GalleryItem } from '../../../../stores/createStore'++const QWEN = 'qwen_image_2.1_int8_convrot.safetensors'+const SDXL = 'sdxl_base.safetensors'++function setup(model: string, type: string, extra: Record<string, unknown> = {}) {+ useCreateStore.setState({+ backend: 'local', isGenerating: false, transparentBackground: false,+ imageModel: model, imageModelList: [{ name: model, type }], cloudOp: null, utilityOp: null, removebg: false,+ ...extra,+ } as never)+ useCreateStore.getState().setMode('image')+}++beforeEach(() => { host.mlx = false })+afterEach(() => { cleanup() })++describe('Schalter Transparent background', () => {+ it('steht bei lokalem Qwen-Image 2.1 und ist standardmaessig aus', () => {+ setup(QWEN, 'qwenimage')+ render(<ParamGroups />)+ const sw = screen.getByRole('switch', { name: /transparent background/i })+ expect(sw.getAttribute('aria-checked')).toBe('false')+ expect(screen.getByText(/see-through background/i)).toBeTruthy()+ })++ it('schaltet sich um und wird gemerkt', () => {+ setup(QWEN, 'qwenimage')+ render(<ParamGroups />)+ fireEvent.click(screen.getByRole('switch', { name: /transparent background/i }))+ expect(useCreateStore.getState().transparentBackground).toBe(true)+ expect(screen.getByRole('switch', { name: /transparent background/i }).getAttribute('aria-checked')).toBe('true')+ })++ it('fehlt bei jedem anderen Modell', () => {+ setup(SDXL, 'sdxl')+ render(<ParamGroups />)+ expect(screen.queryByText('Transparent background')).toBeNull()+ })++ it('fehlt in der Cloud, bei Video und auf dem Mac', () => {+ setup(QWEN, 'qwenimage', { backend: 'cloud' })+ const { unmount } = render(<ParamGroups />)+ expect(screen.queryByText('Transparent background')).toBeNull()+ unmount()+ setup(QWEN, 'qwenimage')+ useCreateStore.getState().setMode('video')+ const v = render(<ParamGroups />)+ expect(screen.queryByText('Transparent background')).toBeNull()+ v.unmount()+ setup(QWEN, 'qwenimage')+ host.mlx = true+ render(<ParamGroups />)+ expect(screen.queryByText('Transparent background')).toBeNull()+ })++ it('fehlt beim Bearbeiten', () => {+ setup(QWEN, 'qwenimage')+ useCreateStore.getState().setIntent('edit')+ render(<ParamGroups />)+ expect(screen.queryByText('Transparent background')).toBeNull()+ })+})++const ITEM = (extra: Partial<GalleryItem>): GalleryItem => ({+ id: 'a', type: 'image', filename: 'lu_00001_.png', subfolder: '', prompt: 'a red apple', negativePrompt: '',+ model: QWEN, modelType: 'qwenimage', seed: 1, steps: 25, cfgScale: 1, sampler: 'euler', scheduler: 'simple',+ width: 1024, height: 1024, batchSize: 1, createdAt: 1, ...extra,+})++describe('Vorschau: Schachbrett', () => {+ it('ein transparentes Bild liegt auf dem Karomuster, ein gewoehnliches nicht', () => {+ const t = render(<ResultView item={ITEM({ transparent: true })} onFullscreen={() => {}} />)+ expect(t.container.querySelector('img')?.className).toContain('lu-checker')+ t.unmount()+ const p = render(<ResultView item={ITEM({})} onFullscreen={() => {}} />)+ expect(p.container.querySelector('img')?.className).not.toContain('lu-checker')+ })++ it('der Ausschnitt aus Remove Background behaelt sein Karomuster', () => {+ const r = render(<ResultView item={ITEM({ intent: 'removebg' })} onFullscreen={() => {}} />)+ expect(r.container.querySelector('img')?.className).toContain('lu-checker')+ })+})+diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.tsindex 4baf358c..33d7b311 100644--- a/src/hooks/useCreate.ts+++ b/src/hooks/useCreate.ts@@ -60,6 +60,7 @@ import { buildWithFixups, wasDeclined, type FixupDeps } from '../lib/render-fixuimport { useDownloadStore } from '../stores/downloadStore'import { useComfyInstallStore } from '../stores/comfyInstallStore'import { checkPromptSafety, SAFETY_BLOCK_MESSAGE } from '../lib/render/safety'+import { wantsTransparent } from '../lib/transparent-image'import { improveKindForIntent } from '../lib/render/improve-prompt'import { improvePrompt } from '../lib/render/improve-prompt-run'import { resolveRunSeed } from '../lib/run-seed'@@ -1014,8 +1015,17 @@ export function useCreate() {}let outputWidth = widthlet outputHeight = height+ // Local Qwen-Image 2.1 text-to-image with "Transparent background": the+ // builder wraps the prompt, SaveImage keeps the alpha channel. Only the+ // dynamic builder knows the switch, so a custom workflow or a fallback+ // graph runs as written and the entry is not marked transparent.+ const transparentRequested = wantsTransparent({+ enabled: state.transparentBackground, intent, isImageToImage: isI2I, isSpecializedLane: !!localOp, modelType: imageModelType,+ })+ const transparentFields = () => (transparentRequested && builderUsed === 'dynamic' ? { transparent: true as const } : {})const baseParams = {- prompt, negativePrompt, model: activeModel, sampler, scheduler, steps, cfgScale, width, height, seed: runSeed, batchSize,+ prompt, negativePrompt,+ ...(transparentRequested ? { transparent: true } : {}), model: activeModel, sampler, scheduler, steps, cfgScale, width, height, seed: runSeed, batchSize,...(isRemoveBg && effInputImage ? { removebg: true, inputImage: effInputImage } : {}),// Discord 2026-09-25 (tbjdrw: "a house becomes a tennis court"): at// strength 1.00 the builder read denoise >= 1 as "no img2img" and@@ -1391,7 +1401,7 @@ export function useCreate() {addToGallery({id: uuid(), type: galleryTypeForFile(file.filename, mode),filename: file.filename, subfolder: file.subfolder ?? '', comfyType: file.type ?? 'output',- prompt, ...improveFields, negativePrompt, model: activeModel,+ prompt, ...improveFields, ...transparentFields(), negativePrompt, model: activeModel,modelType: mode === 'image' ? imageModelType : (videoModelsList.find(m => m.name === activeModel)?.type ?? 'wan'),seed: runSeed,steps, cfgScale, sampler, scheduler, width: outputWidth, height: outputHeight, batchSize,@@ -1482,7 +1492,7 @@ export function useCreate() {addToGallery({id: uuid(), type: galleryTypeForFile(file.filename, mode),filename: file.filename, subfolder: file.subfolder ?? '', comfyType: file.type ?? 'output',- prompt, ...improveFields, negativePrompt, model: activeModel,+ prompt, ...improveFields, ...transparentFields(), negativePrompt, model: activeModel,modelType: mode === 'image' ? imageModelType : (videoModelsList.find(m => m.name === activeModel)?.type ?? 'wan'),seed: runSeed,steps, cfgScale, sampler, scheduler, width: outputWidth, height: outputHeight, batchSize,@@ -1589,7 +1599,7 @@ export function useCreate() {addToGallery({id: uuid(), type: galleryTypeForFile(file.filename, mode),filename: file.filename, subfolder: file.subfolder ?? '', comfyType: file.type ?? 'output',- prompt, ...improveFields, negativePrompt, model: activeModel,+ prompt, ...improveFields, ...transparentFields(), negativePrompt, model: activeModel,modelType: mode === 'image' ? imageModelType : (videoModelsList.find(m => m.name === activeModel)?.type ?? 'wan'),seed: runSeed,steps, cfgScale, sampler, scheduler, width: outputWidth, height: outputHeight, batchSize,diff --git a/src/lib/__tests__/transparent-image.test.ts b/src/lib/__tests__/transparent-image.test.tsnew file mode 100644index 00000000..b232edbd--- /dev/null+++ b/src/lib/__tests__/transparent-image.test.ts@@ -0,0 +1,48 @@+import { describe, it, expect } from 'vitest'+import { itemHasAlpha, supportsTransparent, transparentPrompt, wantsTransparent } from '../transparent-image'++describe('Transparent background: der Prompt', () => {+ it('umhuellt den Prompt wie die offizielle Vorlage es schreibt', () => {+ expect(transparentPrompt('a red apple')).toBe(+ 'This is an RGBA format image with transparency. a red apple. The image has an alpha channel and a transparent background.',+ )+ })++ it('ein Schlusspunkt oder Leerraum des Nutzers wird nicht verdoppelt', () => {+ expect(transparentPrompt(' a red apple. ')).toBe(transparentPrompt('a red apple'))+ expect(transparentPrompt('a red apple...')).toBe(transparentPrompt('a red apple'))+ })++ it('kein Gedankenstrich im Satz, der an das Modell geht', () => {+ expect(transparentPrompt('x')).not.toMatch(/[—–]/)+ })+})++describe('Transparent background: welche Modelle', () => {+ it('nur Qwen-Image 2.1, dessen VAE vier Kanaele schreibt', () => {+ expect(supportsTransparent('qwenimage')).toBe(true)+ for (const t of ['qwenimage1', 'flux', 'flux2', 'zimage', 'sdxl', 'sd15', 'chroma', 'unknown', '', null, undefined]) {+ expect(supportsTransparent(t as string)).toBe(false)+ }+ })++ it('nur ein lokaler Text-zu-Bild-Lauf fragt danach', () => {+ const run = { enabled: true, intent: 'image', isImageToImage: false, isSpecializedLane: false, modelType: 'qwenimage' }+ expect(wantsTransparent(run)).toBe(true)+ expect(wantsTransparent({ ...run, enabled: false })).toBe(false)+ expect(wantsTransparent({ ...run, intent: 'edit' })).toBe(false)+ expect(wantsTransparent({ ...run, intent: 'video' })).toBe(false)+ expect(wantsTransparent({ ...run, isImageToImage: true })).toBe(false)+ expect(wantsTransparent({ ...run, isSpecializedLane: true })).toBe(false)+ expect(wantsTransparent({ ...run, modelType: 'flux' })).toBe(false)+ })+})++describe('Transparent background: die Galerie', () => {+ it('ein Ausschnitt und ein transparentes Bild liegen auf dem Karomuster, ein anderes nicht', () => {+ expect(itemHasAlpha({ intent: 'removebg' })).toBe(true)+ expect(itemHasAlpha({ transparent: true })).toBe(true)+ expect(itemHasAlpha({ intent: 'image' })).toBe(false)+ expect(itemHasAlpha({})).toBe(false)+ })+})diff --git a/src/lib/transparent-image.ts b/src/lib/transparent-image.tsnew file mode 100644index 00000000..70234c68--- /dev/null+++ b/src/lib/transparent-image.ts@@ -0,0 +1,50 @@+// Transparent PNGs from local Qwen-Image 2.1.+//+// Read off the real sources on 2026-10-02, not guessed:+// - Comfy-Org/workflow_templates, templates/image_qwen_image_2_1_t2i.json,+// the note "Transparent Image": wrap the prompt as written below and save+// as PNG to keep the alpha channel.+// - ComfyUI 0.38 comfy/sd.py: the Qwen-Image 2.1 VAE (decoder.head.2.weight+// with 4 output channels, temporal kernel 1) sets output_channels to 4, so+// VAEDecode returns an RGBA image. The official qwen_image_2.1_vae_bf16+// file has exactly that head (safetensors header: [4, 144, 1, 3, 3]).+// - ComfyUI nodes.py SaveImage: Image.fromarray on the 4 channel array writes+// an RGBA PNG. No extra node is needed, the existing SaveImage keeps alpha.+// So the whole feature is the prompt wrapper: the graph is the one the model+// already runs.++/** Model families that can write an alpha channel. */+const TRANSPARENT_FAMILIES: ReadonlySet<string> = new Set(['qwenimage'])++/** Does this model family offer "Transparent background"? Qwen-Image 2.1 only:+ * Qwen-Image 1 and every other family decode three channels. */+export function supportsTransparent(modelType: string | undefined | null): boolean {+ return !!modelType && TRANSPARENT_FAMILIES.has(modelType)+}++/** The prompt wrapper the official template documents. A trailing full stop of+ * the user's own description is dropped so the sentence does not read "..". */+export function transparentPrompt(prompt: string): string {+ const description = prompt.trim().replace(/[.\s]+$/, '')+ return `This is an RGBA format image with transparency. ${description}. The image has an alpha channel and a transparent background.`+}++/** Does this gallery entry carry see-through pixels? A cutout from Remove+ * Background and a transparent Qwen-Image 2.1 render both do, and both sit on+ * a checkerboard instead of solid black. */+export function itemHasAlpha(item: { intent?: string; transparent?: boolean }): boolean {+ return item.intent === 'removebg' || item.transparent === true+}++/** Does this run ask for a transparent picture? Only a local text-to-image+ * run on a family that can write alpha: an edit, a specialized lane and every+ * other family ignore the switch. */+export function wantsTransparent(run: {+ enabled: boolean+ intent: string+ isImageToImage: boolean+ isSpecializedLane: boolean+ modelType: string | undefined | null+}): boolean {+ return run.enabled && run.intent === 'image' && !run.isImageToImage && !run.isSpecializedLane && supportsTransparent(run.modelType)+}diff --git a/src/stores/createStore.ts b/src/stores/createStore.tsindex e681b2b2..35b9e223 100644--- a/src/stores/createStore.ts+++ b/src/stores/createStore.ts@@ -242,6 +242,9 @@ export interface GalleryItem {/** "Improve my prompt" was on but the rewrite failed, the run used the* user's own prompt. Said in the details, nowhere else. */improveFailed?: boolean+ /** Local Qwen-Image 2.1 with "Transparent background": the PNG carries an+ * alpha channel, so tiles and previews sit on a checkerboard. */+ transparent?: boolean/** MLX video (Mac, Apple Silicon): absolute filesystem path of the finished* mp4, as returned by `video_generate`'s `output` field. Playback/download* go through `dataUrl` (a blob: URL, see above) instead — this is kept@@ -378,6 +381,11 @@ interface CreateState {cloudStudioCredits: number | null/** Runtime-only: images per cloud run, 1 to 4 (Image and Edit). */cloudImageCount: number+ /** Local Qwen-Image 2.1 only: write the picture with a transparent background+ * (lib/transparent-image.ts). A preference like the HiRes switch, so it is+ * remembered. */+ transparentBackground: boolean+ setTransparentBackground: (on: boolean) => void/** Advanced settings switch: a chat model rewrites the prompt before a run. Off by default, remembered. */improvePrompt: booleansetImprovePrompt: (on: boolean) => void@@ -697,6 +705,7 @@ export const useCreateStore = create<CreateState>()(cloudStudioCredits: null as number | null,cloudImageCount: 1,improvePrompt: false,+ transparentBackground: false,localOpModel: '',charactersVersion: 0,caps: { rmbg: false, 'inpaint-nodes': false, dwpose: false } as Record<'rmbg' | 'inpaint-nodes' | 'dwpose', boolean>,@@ -949,6 +958,7 @@ export const useCreateStore = create<CreateState>()(setCloudStudioCredits: (cloudStudioCredits) => set({ cloudStudioCredits }),setCloudImageCount: (count) => set({ cloudImageCount: clampImageCount(count) }),setImprovePrompt: (on) => set({ improvePrompt: on === true }),+ setTransparentBackground: (on) => set({ transparentBackground: on === true }),// Picking a lane model adopts its architecture defaults (like// setVideoModel does) — an inherited 1024×1024 from the Image tab would// OOM a 14B S2V run on consumer VRAM.@@ -1201,6 +1211,7 @@ export const useCreateStore = create<CreateState>()(musicDuration: state.musicDuration,musicHowtoSeen: state.musicHowtoSeen,improvePrompt: state.improvePrompt,+ transparentBackground: state.transparentBackground,triggerWord: state.triggerWord,trainSteps: state.trainSteps,// Studio: the picked step's option values are a preference like the