The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Image models render at the sizes they were trained on, cropped to the ratio asked
Adarshfdaf86776879
diff --git a/scripts/comfy/build-library.mjs b/scripts/comfy/build-library.mjsindex c27547e6..9dfd5397 100644--- a/scripts/comfy/build-library.mjs+++ b/scripts/comfy/build-library.mjs@@ -412,6 +412,15 @@ async function main() {if (frameStep) defaults.frameStep = frameStep;Object.assign(defaults, spec.defaults || {});+ // ---- trained canvases: each on the graph's grid and inside its limits+ for (const [tier, list] of Object.entries(spec.sizes?.tiers || {})) {+ for (const [w, h] of list) {+ const m = limits.dimensionMultiple || 16;+ if (w % m || h % m) errs.push(`sizes ${tier} ${w}x${h}: not on the ${m} px grid`);+ if (w > (limits.maxWidth ?? Infinity) || h > (limits.maxHeight ?? Infinity)) errs.push(`sizes ${tier} ${w}x${h}: past maxWidth / maxHeight`);+ }+ }+// ---- modelsconst userModelTargets = new Set(Object.entries(bindings).filter(([k]) => USER_MODEL_KEYS.has(k)).flatMap(([, ts]) => ts.map((t) => `${t.node}.${t.input}`)),@@ -500,6 +509,8 @@ async function main() {outputs: spec.outputs,defaults,limits,+ // The canvases the model was trained on (src/lib/comfy.ts TrainedSizes): the app renders one and crops to the ratio asked.+ ...(spec.sizes && { sizes: spec.sizes }),models: [...models.values()],customNodes,vramGb: spec.vramGb,diff --git a/scripts/comfy/library.spec.mjs b/scripts/comfy/library.spec.mjsindex 1228c7d9..eaced98e 100644--- a/scripts/comfy/library.spec.mjs+++ b/scripts/comfy/library.spec.mjs@@ -914,6 +914,7 @@ const qwen21Tier = (op, tier, base, extra) => ({bindings: { ...base.bindings, seed: [b('70', 'noise_seed')], vae: [b('3', 'vae_name')], ...(tier === 'fast' && { sigmas: [b('73', 'sigmas')] }) },outputs: [{ node: base.output ?? '90', kind: 'image' }],...(base.limits && { limits: base.limits }),+ ...(base.sizes && { sizes: base.sizes }),...(base.packs && { packs: base.packs }),vramGb: 20,optionalModels: [QWEN21_CLEAN_VAE],@@ -945,6 +946,36 @@ const OJ_H3_LICENCE ='commercial use above US$20M yearly revenue needs MiniMax\'s written authorization; show "MiniMax H3" on the product\'s interface; no outputs used to improve other AI models · ' +'Qwen3-VL 8B describer Apache-2.0 · SAM 3.1 under Meta\'s SAM License · graphs from D3voz/openjutsu (MIT) · Context Loop nodes GPL-3.0, Fantastic PromptBuilder MIT, H3 OneClick Swap MIT';+// ---- Trained canvases (manifest `sizes`, src/lib/comfy.ts TrainedSizes): what each model was trained on, so a run renders+// one of them and the app crops the result to the aspect ratio asked when none has that shape.+const bothWays = (sizes) => sizes.flatMap(([w, h]) => (w === h ? [[w, h]] : [[w, h], [h, w]]));+// Qwen-Image 2.1: native about 4 MP (2048x2048, 2400x1792, 2528x1696, 2752x1536); 1K and 1.5K are the same shapes at about+// 1 MP and 2.3 MP on its 32 px grid.+const QWEN21_SIZES = {+ tiers: {+ '1K': bothWays([[1024, 1024], [1152, 864], [1248, 832], [1376, 768]]),+ '1.5K': bothWays([[1536, 1536], [1760, 1312], [1856, 1248], [2048, 1152]]),+ '2K': bothWays([[2048, 2048], [2400, 1792], [2528, 1696], [2752, 1536]]),+ },+};+// Qwen-Image (2512): the model card's aspect-ratio table.+const QWEN2512_SIZES = { tiers: { '1K': bothWays([[1328, 1328], [1664, 928], [1472, 1104], [1584, 1056]]) } };+// HiDream I1: its 1 MP training buckets.+const HIDREAM_SIZES = { tiers: { '1K': bothWays([[1024, 1024], [1360, 768], [1168, 880], [1248, 832]]) } };+// SDXL: its 1 MP training buckets on a 64 px grid.+const SDXL_SIZES = { tiers: { '1K': bothWays([[1024, 1024], [1152, 896], [1216, 832], [1344, 768], [1536, 640]]) } };+// MiniMax H3 Image: the shapes its card lists (1:1, 4:3, 3:2, 16:9, 21:9) at about 4 MP and 16 MP.+const H3_IMAGE_SIZES = {+ tiers: {+ '2K': bothWays([[2048, 2048], [2368, 1760], [2496, 1664], [2720, 1536], [3136, 1344]]),+ '4K': bothWays([[4096, 4096], [4736, 3552], [5024, 3360], [5472, 3072], [6272, 2688]]),+ },+};+// Krea 2: the shorter side at least 1024 and the longer at most 2048.+const KREA2_SIZES = { minSide: 1024, maxSide: 2048 };+// FLUX.1: up to about 2 MP.+const FLUX1_SIZES = { maxMegapixels: 2 };+export const SPEC = [// =========================================================================// IMAGE@@ -969,6 +1000,7 @@ export const SPEC = [},outputs: [{ node: '9', kind: 'image' }],limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 16 },+ sizes: FLUX1_SIZES,vramGb: 24,notes: 'No negative prompt (cfg 1, distilled guidance). FluxGuidance node 1001 added so guidance is bindable (template implicit default is also 3.5). fp16 weights (23.8 GB) — ComfyUI offloads on 16-24 GB cards; set weight_dtype fp8 in node 194:46 for lower VRAM.',},@@ -990,6 +1022,7 @@ export const SPEC = [},outputs: [{ node: '9', kind: 'image' }],limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 16 },+ sizes: FLUX1_SIZES,vramGb: 16,notes: 'Photorealistic "opinionated" FLUX.1 dev fine-tune by Krea (fp8 scaled weights). Shares text encoders + ae.safetensors with flux1-dev-t2i.',},@@ -1007,6 +1040,7 @@ export const SPEC = [},outputs: [{ node: '9', kind: 'image' }],limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 16 },+ sizes: FLUX1_SIZES,vramGb: 24,notes: '4-step distilled, Apache-2.0 licence (commercial OK). Prompt goes to both CLIP-L and T5 fields of CLIPTextEncodeFlux. Guidance is ignored by schnell.',},@@ -1123,6 +1157,7 @@ export const SPEC = [},outputs: [{ node: '60', kind: 'image' }],limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 16 },+ sizes: QWEN2512_SIZES,vramGb: 24,notes: 'Best open model for in-image text rendering (EN/ZH). Native 1328x1328; recommended sizes 1664x928 (16:9), 928x1664 (9:16), 1472x1104 (4:3). 50 steps cfg 4 by default.',},@@ -1144,6 +1179,7 @@ export const SPEC = [},outputs: [{ node: '60', kind: 'image' }],limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 16 },+ sizes: QWEN2512_SIZES,vramGb: 24,notes: 'Official template with "Enable 4 Steps LoRA" on (Qwen-Image-2512-Lightning-4steps, cfg 1). ~10x faster than qwen-image-2512-t2i.',},@@ -1183,6 +1219,7 @@ export const SPEC = [},outputs: [{ node: '9', kind: 'image' }],limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 16 },+ sizes: HIDREAM_SIZES,vramGb: 24,notes: '17B MoE (fp8). Four text encoders incl. Llama-3.1-8B (fp8). Dev variant: 28 steps, cfg 1, lcm sampler; negative prompt has little effect at cfg 1.',},@@ -1203,6 +1240,7 @@ export const SPEC = [},outputs: [{ node: '7', kind: 'image' }],limits: { maxWidth: 1536, maxHeight: 1536, dimensionMultiple: 8 },+ sizes: SDXL_SIZES,vramGb: 8,notes: 'Lightweight baseline (single 6.9 GB checkpoint). Native 1024x1024 class resolutions. Default negative prompt replaced with a generic one.',},@@ -1316,6 +1354,7 @@ export const SPEC = [},outputs: [{ node: '9', kind: 'image' }],limits: { maxWidth: 6272, maxHeight: 6272, dimensionMultiple: 32 },+ sizes: H3_IMAGE_SIZES,// The Prompt helper's Qwen3.5 9B is needed only when it is on (its nodes are taken out otherwise).optionalModels: ['qwen3.5_9b_w4a8_gptq.safetensors'],vramGb: 32,@@ -3626,6 +3665,7 @@ export const SPEC = [},outputs: [{ node: '29', kind: 'image' }],limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 16 },+ sizes: KREA2_SIZES,vramGb: 20,license: 'Krea 2 Community License (free for individuals and small teams; enterprise terms above the thresholds); LoRA by Ostris under the same licence',notes:@@ -3642,6 +3682,7 @@ export const SPEC = [},outputs: [{ node: '26', kind: 'image' }],limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 16 },+ sizes: FLUX1_SIZES,vramGb: 20,license: 'USO LoRA/projector Apache-2.0, but the FLUX.1 [dev] base is NON-COMMERCIAL (outputs may be used commercially per the BFL licence; running it as a paid service is not)',notes: 'ByteDance USO style-only reference: each USOStyleReference stacks one more style image (CLIPVisionEncode + USOStyleReference pairs). 20 steps, guidance 3.5, cfg 1.',@@ -3703,14 +3744,15 @@ export const SPEC = [prompt: [b('4', 'prompt')], width: [b('5', 'width')], height: [b('5', 'height')], seed: [b('6', 'seed')], steps: [b('6', 'steps')], vae: [b('3', 'vae_name')],},outputs: [{ node: '9', kind: 'image' }],- limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 32 },+ limits: { maxWidth: 2752, maxHeight: 2752, dimensionMultiple: 32 },+ sizes: QWEN21_SIZES,vramGb: 20,optionalModels: [QWEN21_CLEAN_VAE],license: `Qwen Research License Agreement (Qwen-Image 2.1): NON-COMMERCIAL, research and evaluation only${QWEN21_CLEAN_LICENCE}`,notes:'The Qwen-Image 2.1 text-to-image workflow, its subgraph flattened: int8 model, Qwen3-VL 8B int8 text encoder (type qwen_image), ' +'TextEncodeQwenImage21 (no negative, resolution 1024, no images), EmptyLatentImage, KSampler 25 steps, cfg 1, euler, simple, denoise 1. ' +- 'Removed: the ResolutionSelector (width/height bind the latent, multiples of 32, native up to 2048x2048) and the SaveImageAdvanced (SaveImage after SplitImageWithAlpha, as the Qwen 2.1 VAE decodes four channels). ' ++ 'Removed: the ResolutionSelector (width/height bind the latent, multiples of 32; its native sizes go up to 2752x1536, listed in sizes) and the SaveImageAdvanced (SaveImage after SplitImageWithAlpha, as the Qwen 2.1 VAE decodes four channels). ' +'cfg 1: no negative prompt.' + QWEN21_CLEAN_NOTE,},{@@ -3893,9 +3935,9 @@ export const SPEC = [// ---- Qwen-Image 2.1 in 2-6 steps (Options → Speed), the 2.1 Next-Scene LoRA, and a 16 GB route ---------------------------// Each speed graph is its base graph with one LoRA + ManualSigmas branch (qwen21Tier above); the provider picks it from// params.extra.speed (src/lib/comfy-variants.ts). Turbo is qwen-image-21-turbo-edit; Full is the base graph.- qwen21Tier('t2i', 'draft', { title: 'Qwen-Image 2.1 Text to Image', capability: 't2i', bindings: { prompt: [b('4', 'prompt')], width: [b('5', 'width')], height: [b('5', 'height')] }, output: '9', limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 32 } }),- qwen21Tier('t2i', 'fast', { title: 'Qwen-Image 2.1 Text to Image', capability: 't2i', bindings: { prompt: [b('4', 'prompt')], width: [b('5', 'width')], height: [b('5', 'height')] }, output: '9', limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 32 } }),- qwen21Tier('t2i', 'details', { title: 'Qwen-Image 2.1 Text to Image', capability: 't2i', bindings: { prompt: [b('4', 'prompt')], width: [b('5', 'width')], height: [b('5', 'height')] }, output: '9', limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 32 } }),+ qwen21Tier('t2i', 'draft', { title: 'Qwen-Image 2.1 Text to Image', capability: 't2i', bindings: { prompt: [b('4', 'prompt')], width: [b('5', 'width')], height: [b('5', 'height')] }, output: '9', limits: { maxWidth: 2752, maxHeight: 2752, dimensionMultiple: 32 }, sizes: QWEN21_SIZES }),+ qwen21Tier('t2i', 'fast', { title: 'Qwen-Image 2.1 Text to Image', capability: 't2i', bindings: { prompt: [b('4', 'prompt')], width: [b('5', 'width')], height: [b('5', 'height')] }, output: '9', limits: { maxWidth: 2752, maxHeight: 2752, dimensionMultiple: 32 }, sizes: QWEN21_SIZES }),+ qwen21Tier('t2i', 'details', { title: 'Qwen-Image 2.1 Text to Image', capability: 't2i', bindings: { prompt: [b('4', 'prompt')], width: [b('5', 'width')], height: [b('5', 'height')] }, output: '9', limits: { maxWidth: 2752, maxHeight: 2752, dimensionMultiple: 32 }, sizes: QWEN21_SIZES }),qwen21Tier('edit', 'draft', { title: 'Qwen-Image 2.1 Image Edit (up to 4 references)', capability: 'edit', bindings: { prompt: [b('30', 'prompt')], image: [b('10', 'image')], image2: [b('11', 'image')], image3: [b('12', 'image')], image4: [b('13', 'image')] }, limits: { maxWidth: 2048, maxHeight: 2048 } }),qwen21Tier('edit', 'fast', { title: 'Qwen-Image 2.1 Image Edit (up to 4 references)', capability: 'edit', bindings: { prompt: [b('30', 'prompt')], image: [b('10', 'image')], image2: [b('11', 'image')], image3: [b('12', 'image')], image4: [b('13', 'image')] }, limits: { maxWidth: 2048, maxHeight: 2048 } }),qwen21Tier('edit', 'details', { title: 'Qwen-Image 2.1 Image Edit (up to 4 references)', capability: 'edit', bindings: { prompt: [b('30', 'prompt')], image: [b('10', 'image')], image2: [b('11', 'image')], image3: [b('12', 'image')], image4: [b('13', 'image')] }, limits: { maxWidth: 2048, maxHeight: 2048 } }),@@ -3957,7 +3999,8 @@ export const SPEC = [prompt: [b('5', 'prompt')], width: [b('5', 'width')], height: [b('5', 'height')], seed: [b('6', 'seed')], steps: [b('6', 'steps')], vae: [b('3', 'vae_name')],},outputs: [{ node: '90', kind: 'image' }],- limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 32 },+ limits: { maxWidth: 2752, maxHeight: 2752, dimensionMultiple: 32 },+ sizes: QWEN21_SIZES,vramGb: 16,optionalModels: [QWEN21_CLEAN_VAE],requiredModels: ['adapter_v12.safetensors'],@@ -4087,6 +4130,7 @@ export const SPEC = [},outputs: [{ node: '29', kind: 'image' }],limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 16 },+ sizes: KREA2_SIZES,vramGb: 20,license: 'Krea 2 Community License (free under US$1M yearly revenue; enterprise terms above it); Krea2-realism-V2 LoRA MIT',notes:@@ -4102,6 +4146,7 @@ export const SPEC = [bindings: { prompt: [b('6', 'text')], width: [b('5', 'width')], height: [b('5', 'height')], seed: [b('3', 'seed')], steps: [b('3', 'steps')] },outputs: [{ node: '29', kind: 'image' }],limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 16 },+ sizes: KREA2_SIZES,vramGb: 20,license: 'Krea 2 Community License (free under US$1M yearly revenue; enterprise terms above it)',notes:@@ -4119,6 +4164,7 @@ export const SPEC = [},outputs: [{ node: '29', kind: 'image' }],limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 16 },+ sizes: KREA2_SIZES,vramGb: 20,license:'Krea 2 Community License (free under US$1M yearly revenue; enterprise terms above it); the Krea 2 General Edit V2 LoRA is NON-COMMERCIAL (commercial use needs a licence from its author)',@@ -4140,6 +4186,7 @@ export const SPEC = [},outputs: [{ node: '29', kind: 'image' }],limits: { maxWidth: 2048, maxHeight: 2048, dimensionMultiple: 16 },+ sizes: KREA2_SIZES,vramGb: 20,license:'Krea 2 Community License (free under US$1M yearly revenue; enterprise terms above it); the Krea 2 Identity Edit V2 LoRA is NON-COMMERCIAL (commercial use needs a licence from its author)',diff --git a/src/lib/comfy-compose.ts b/src/lib/comfy-compose.tsindex 7bb6e54e..b66b993b 100644--- a/src/lib/comfy-compose.ts+++ b/src/lib/comfy-compose.ts@@ -14,7 +14,6 @@ import {asrLanguage,bypassNode,bypassReference,- computeDimensions,fitCanvas,computeFrames,dropBranch,@@ -37,6 +36,7 @@ import {tagMetaBatch,whisperLanguage,withLoad3dImages,+ workflowCanvas,type BindingKey,type CaptionCue,type ComfyWorkflow,@@ -608,8 +608,9 @@ export async function composeWorkflow(endpointTemplate: string, input: GenInput,// References (Pika H3 Flex Ref2VA) are not frames: the aspect ratio asked for holds ("auto" takes Image 1's shape).const asFrames = h3 && (ctx.op === "i2v" || ctx.op === "flf2v" || (!!b.image && manifest.expand !== "references"));const aspectRatio = asFrames || (h3 && ctx.op === "avatar") ? "auto" : (followClip && !input.aspectRatio) || followDriver ? "auto" : input.aspectRatio;+ // The centre the saved picture is cropped to (a trained canvas of another shape than the one asked).+ let cropTo: { width: number; height: number } | undefined;if (b.width || b.height) {- const multiple = Number(manifest.limits?.dimensionMultiple ?? 16);// With motion paths the frame keeps the start image's shape, so the paths need no cropping;// "auto" keeps the source clip's shape when its header told us.const srcAspect = (extra.motionPaths as MotionPaths | undefined)?.aspect;@@ -621,13 +622,12 @@ export async function composeWorkflow(endpointTemplate: string, input: GenInput,// H3's own canvas (ComfyUI's adapt_canvas): 768 px on the short side, at most 768 × 1344, multiples of 32.Object.assign(values, h3Canvas(shape));} else {- const dims = computeDimensions(shape, input.resolution, { width: Number(d.width ?? 1024), height: Number(d.height ?? 1024) }, multiple);- // Respect the workflow's size limits while keeping the aspect ratio.- const maxW = Number(manifest.limits?.maxWidth ?? Infinity);- const maxH = Number(manifest.limits?.maxHeight ?? Infinity);- const k = Math.min(1, maxW / dims.width, maxH / dims.height);- values.width = Math.max(multiple, Math.floor((dims.width * k) / multiple) * multiple);- values.height = Math.max(multiple, Math.floor((dims.height * k) / multiple) * multiple);+ // The model's trained canvas nearest the shape asked (manifest `sizes`), inside the workflow's limits; one that isn't+ // that shape is cropped to it once saved (meta.cropTo, generations.ts).+ const canvas = workflowCanvas(manifest, shape, input.resolution);+ values.width = canvas.width;+ values.height = canvas.height;+ cropTo = canvas.crop;}}// An end card appended to an ad (video-append-endcard): the card is encoded at the ad's own size and frame rate,@@ -1190,6 +1190,7 @@ export async function composeWorkflow(endpointTemplate: string, input: GenInput,if (b.width && b.height && (extra.width !== undefined || extra.height !== undefined)) {const [w, h] = [Number(values.width), Number(values.height)];if (w > 0 && h > 0 && Number.isFinite(w * h)) Object.assign(values, fitCanvas(w, h, manifest.limits));+ cropTo = undefined;}if (audio2 && ctx.op !== "dialogue" && ctx.op !== "voice-change") values.audio2 = audio2;// Soundtrack mix: a silent bed as long as the video, so neither track cuts the other short.@@ -1435,6 +1436,7 @@ export async function composeWorkflow(endpointTemplate: string, input: GenInput,...(metaBatch ? { metaBatch: true } : {}),...(b.seed && typeof values.seed === "number" ? { seed: values.seed } : {}),...(reviewInputs ? { reviewInputs } : {}),+ ...(cropTo ? { cropTo } : {}),},};}diff --git a/src/lib/comfy.ts b/src/lib/comfy.tsindex 27c85af6..b2b40702 100644--- a/src/lib/comfy.ts+++ b/src/lib/comfy.ts@@ -116,6 +116,8 @@ export interface ManifestWorkflow {outputs: ManifestOutput[];defaults: Record<string, number | string | boolean>;limits?: Record<string, number>;+ /** The canvases the model was trained on (workflowCanvas picks from them): absent, any canvas computeDimensions makes. */+ sizes?: TrainedSizes;models: ManifestModel[];customNodes: { name: string; repo: string }[];vramGb?: number | string;@@ -307,6 +309,129 @@ export function computeDimensions(return { width: roundTo(height * ratio, multiple), height: roundTo(height, multiple) };}+/**+ * The canvases a model was trained on (a workflow's manifest `sizes`). `tiers`: the exact sizes per resolution tier, each+ * [width, height], both orientations listed; a tier it doesn't list takes the nearest listed one by area (a 1.5K ask on a+ * model trained at about 1.7 MP renders those sizes). Or a range, on the canvas computeDimensions makes: `maxMegapixels`+ * (the area at most, 1 MP = 1,000,000 px), `minSide` (the shorter side at least), `maxSide` (the longer side at most).+ */+export interface TrainedSizes {+ tiers?: Record<string, [number, number][]>;+ minSide?: number;+ maxSide?: number;+ maxMegapixels?: number;+}++/**+ * The canvas a workflow renders. `crop`: when the canvas is the trained shape nearest to the aspect ratio asked (not that+ * ratio), the centre of the result the run keeps, which has the ratio asked (the server crops the saved picture to it).+ */+export interface WorkflowCanvas {+ width: number;+ height: number;+ crop?: { width: number; height: number };+}++/** Within 1% of the ratio asked counts as that ratio (a canvas on the model's grid is rarely exact): no crop. */+const RATIO_TOLERANCE = 0.01;++const ratioGap = (a: number, b: number) => Math.abs(Math.log(a / b));++/**+ * The centre crop of a width × height picture that has the aspect ratio `ratio` (the largest such area), or undefined+ * when the picture has that ratio already (within 1%).+ */+export function cropToRatio(width: number, height: number, ratio: number): { width: number; height: number } | undefined {+ if (!(width > 0 && height > 0 && ratio > 0) || ratioGap(width / height, ratio) <= Math.log(1 + RATIO_TOLERANCE)) return undefined;+ return width / height > ratio ? { width: Math.min(width, Math.round(height * ratio)), height } : { width, height: Math.min(height, Math.round(width / ratio)) };+}++/** The listed tier nearest to `area` (by the mean area of its sizes, on a log scale). */+function nearestTier(tiers: Record<string, [number, number][]>, area: number): [number, number][] | undefined {+ let best: [number, number][] | undefined;+ let gap = Infinity;+ for (const sizes of Object.values(tiers)) {+ if (!sizes.length) continue;+ const mean = sizes.reduce((sum, [w, h]) => sum + w * h, 0) / sizes.length;+ const g = ratioGap(mean, area);+ if (g < gap) [best, gap] = [sizes, g];+ }+ return best;+}++/**+ * The trained canvas for an aspect ratio and a resolution tier (TrainedSizes), or null when the model's sizes don't change+ * what computeDimensions makes: no `sizes`, or a range the canvas is inside already.+ */+export function trainedDimensions(+ sizes: TrainedSizes | undefined,+ ratio: number,+ resolution: string | undefined,+ defaults: { width: number; height: number },+ multiple = 16,+): { width: number; height: number } | null {+ if (!sizes || !(ratio > 0)) return null;+ const area = (resolution && RES_AREA[resolution]) || defaults.width * defaults.height;+ const tiers = sizes.tiers && Object.keys(sizes.tiers).length ? sizes.tiers : undefined;+ if (tiers) {+ const list = (resolution && tiers[resolution]?.length ? tiers[resolution] : undefined) ?? nearestTier(tiers, area);+ if (!list?.length) return null;+ // The size whose shape is nearest the ratio asked (the first listed of equals).+ const [width, height] = list.reduce((best, s) => (ratioGap(s[0] / s[1], ratio) < ratioGap(best[0] / best[1], ratio) ? s : best));+ return { width, height };+ }+ const maxArea = sizes.maxMegapixels ? sizes.maxMegapixels * 1e6 : Infinity;+ let changed = area > maxArea;+ let w = Math.sqrt(Math.min(area, maxArea) * ratio);+ let h = Math.sqrt(Math.min(area, maxArea) / ratio);+ const scale = (k: number) => {+ [w, h, changed] = [w * k, h * k, true];+ };+ if (sizes.minSide && Math.min(w, h) < sizes.minSide) scale(sizes.minSide / Math.min(w, h));+ if (sizes.maxSide && Math.max(w, h) > sizes.maxSide) scale(sizes.maxSide / Math.max(w, h));+ // Both bounds can't hold at this shape (21:9 inside 1024-2048): the shorter side stays at its least, and the result is+ // cropped to the ratio asked.+ if (sizes.minSide && Math.min(w, h) < sizes.minSide) {+ if (w < h) w = sizes.minSide;+ else h = sizes.minSide;+ }+ if (!changed) return null;+ let width = roundTo(w, multiple);+ let height = roundTo(h, multiple);+ // The grid never takes a side past a bound.+ const { minSide, maxSide } = sizes;+ if (minSide) [width, height] = [width, height].map((v) => (v < minSide ? Math.ceil(minSide / multiple) * multiple : v)) as [number, number];+ if (maxSide) [width, height] = [width, height].map((v) => (v > maxSide ? Math.max(multiple, Math.floor(maxSide / multiple) * multiple) : v)) as [number, number];+ return { width, height };+}++/**+ * The canvas a workflow renders for an aspect ratio and a resolution tier, as every caller sizes it (the composer, and the+ * run's size for limits and prices): its trained size when the manifest lists `sizes`, else computeDimensions on the+ * workflow's default area; on its grid, scaled down whole inside its maxWidth / maxHeight. A trained canvas whose shape+ * isn't the ratio asked carries the centre `crop` that is. A workflow without `sizes` (or a canvas inside its range)+ * renders what it always did, uncropped.+ */+export function workflowCanvas(+ manifest: Pick<ManifestWorkflow, "defaults" | "limits" | "sizes">,+ aspectRatio: string | undefined,+ resolution: string | undefined,+): WorkflowCanvas {+ const d = manifest.defaults ?? {};+ const defaults = { width: Number(d.width ?? 1024), height: Number(d.height ?? 1024) };+ const multiple = Number(manifest.limits?.dimensionMultiple ?? 16);+ const asked = aspectRatio ? parseRatio(aspectRatio) : null;+ const trained = trainedDimensions(manifest.sizes, asked || defaults.width / defaults.height, resolution, defaults, multiple);+ const dims = trained ?? computeDimensions(aspectRatio, resolution, defaults, multiple);+ const maxW = Number(manifest.limits?.maxWidth ?? Infinity);+ const maxH = Number(manifest.limits?.maxHeight ?? Infinity);+ const k = Math.min(1, maxW / dims.width, maxH / dims.height);+ const width = Math.max(multiple, Math.floor((dims.width * k) / multiple) * multiple);+ const height = Math.max(multiple, Math.floor((dims.height * k) / multiple) * multiple);+ const crop = trained && asked ? cropToRatio(width, height, asked) : undefined;+ return { width, height, ...(crop && { crop }) };+}+/*** A canvas the request names (params.extra.width / height: a layout's, Soul's exact sizes) on the workflow's grid and* inside its maxWidth / maxHeight, the shape kept: rounded to the grid, then scaled down whole when a side is past itsdiff --git a/src/server/crop-picture.ts b/src/server/crop-picture.tsindex 8cd28f65..3f72ef9b 100644--- a/src/server/crop-picture.ts+++ b/src/server/crop-picture.ts@@ -1,5 +1,10 @@import "server-only";+import fs from "node:fs";+import sharp from "sharp";+import type { OutputFile } from "@/lib/catalog/types";+import { cropToRatio } from "@/lib/comfy";import { decodePng, encodePng } from "./png";+import { absolutePath, getAsset, rewriteAsset } from "./storage";/** Fractional crop window: [x, y, width, height], each 0–1 of the image's dimensions. */export type CropWindow = [x: number, y: number, w: number, h: number];@@ -29,3 +34,33 @@ export function cropPicture(png: Buffer, crop: CropWindow): Buffer {}return encodePng({ width: w, height: h, data: out });}++/** The centre a run's composer asked its saved pictures to be cropped to (meta.cropTo: a size on the canvas it rendered). */+export function askedCrop(meta: Record<string, unknown> | undefined): { width: number; height: number } | undefined {+ const c = meta?.cropTo as { width?: unknown; height?: unknown } | undefined;+ const ok = (v: unknown): v is number => typeof v === "number" && Number.isFinite(v) && v > 0;+ return c && ok(c.width) && ok(c.height) ? { width: c.width, height: c.height } : undefined;+}++/**+ * A saved picture cropped in place to the aspect ratio of `crop` (its centre; comfy.ts cropToRatio), in the format it+ * was saved in: a model trained on other shapes renders its nearest one, and the run keeps the shape asked. A picture+ * that has that shape already (within 1%), a file that isn't a picture sharp reads, and one that is gone stay as they are.+ */+export async function cropSavedToRatio(o: OutputFile, crop: { width: number; height: number }): Promise<OutputFile> {+ if (o.kind !== "image" || !o.assetId) return o;+ const asset = getAsset(o.assetId);+ if (!asset || !/^image\/(png|jpeg|webp)$/.test(asset.contentType)) return o;+ // Read whole first: the file is written over below.+ const input = await fs.promises.readFile(absolutePath(asset.relPath)).catch(() => null);+ if (!input) return o;+ const meta = await sharp(input, { failOn: "error", limitInputPixels: 64 * 2 ** 20 }).metadata().catch(() => null);+ if (!meta?.width || !meta.height) return o;+ const box = cropToRatio(meta.width, meta.height, crop.width / crop.height);+ if (!box) return o;+ let img = sharp(input, { limitInputPixels: 64 * 2 ** 20 }).extract({ left: Math.floor((meta.width - box.width) / 2), top: Math.floor((meta.height - box.height) / 2), width: box.width, height: box.height });+ img = meta.format === "jpeg" ? img.jpeg({ quality: 95 }) : meta.format === "webp" ? img.webp({ lossless: true }) : img.png();+ const data = await img.toBuffer();+ rewriteAsset(asset.id, data);+ return { ...o, ...(o.width !== undefined && { width: box.width }), ...(o.height !== undefined && { height: box.height }) };+}diff --git a/src/server/generations.ts b/src/server/generations.tsindex 792a728a..be781b7e 100644--- a/src/server/generations.ts+++ b/src/server/generations.ts@@ -146,7 +146,7 @@ import { modelToFinish, startModelFinish, startTurntable, stopModelFinish, typeimport { stopPreviews, tickPreviews } from "./model3d-preview";import { finishTask, pathOnWorker, poolFinishes3d, startWorkerModelFinish, stopWorkerFinish } from "./computer/finish";import { PATH_FPS, PATH_FRAMES } from "@/lib/camera-path";-import { cropPicture, isCropWindow } from "./crop-picture";+import { askedCrop, cropPicture, cropSavedToRatio, isCropWindow } from "./crop-picture";import { convertMask, decodePng, encodePng } from "./png";import { engineMode, getSetting, runFailureDetail, withCandidates, withoutCandidates } from "./settings";import { blockedForAccounts, discardBody, fetchRemoteToFile, RemoteFetchError } from "./remote-fetch";@@ -4770,6 +4770,17 @@ async function pollOne(r: Row): Promise<void> {}}}+ // A picture rendered at the model's trained size nearest the shape asked is cropped to that shape (comfy.ts+ // workflowCanvas): the composer named the centre to keep (meta.cropTo). A crop that fails keeps the picture as made.+ const keep = askedCrop(ctx.meta);+ if (keep) {+ for (const [i, o] of outputs.entries()) {+ outputs[i] = await cropSavedToRatio(o, keep).catch((e: unknown) => {+ console.warn(`[fuobe] could not crop output for ${r.id}: ${(e as Error).message}`);+ return o;+ });+ }+ }// Ideogram 4's grey "blocked by safety filter" card is no picture (src/server/safety-card.ts): it is left out of the// results and kept for the owner only (keepForOwner), with its measures. A run that got some real pictures keeps them.// A run whose every picture was the card is made again in its place (declinedAgain: Auto's fallbacks in order);diff --git a/src/server/hosted.ts b/src/server/hosted.tsindex e30ad676..471f0384 100644--- a/src/server/hosted.ts+++ b/src/server/hosted.ts@@ -1,6 +1,6 @@import "server-only";import { getModel } from "@/lib/catalog";-import { computeDimensions, fitCanvas } from "@/lib/comfy";+import { computeDimensions, fitCanvas, workflowCanvas } from "@/lib/comfy";import { requestWorkflowId } from "@/lib/comfy-variants";import { h3Canvas, isH3Graph } from "@/lib/h3-prompt";import { pictureCanvas } from "@/lib/openjutsu-graphs";@@ -534,10 +534,9 @@ function workflowSize(req: GenerationRequest, endpoint: string, modelId: string)const follows = !asked || asked === "auto" || (h3 && !!b.image);const shape = follows && src ? `${src.width}:${src.height}` : asked === "auto" ? undefined : asked;if (h3) return h3Canvas(shape);- const multiple = Number(manifest.limits?.dimensionMultiple ?? 16);- const dims = computeDimensions(shape, req.params?.resolution ?? model?.defaults?.resolution, { width: Number(d.width ?? 1024), height: Number(d.height ?? 1024) }, multiple);- const k = Math.min(1, maxW / dims.width, maxH / dims.height);- return { width: Math.max(multiple, Math.floor((dims.width * k) / multiple) * multiple), height: Math.max(multiple, Math.floor((dims.height * k) / multiple) * multiple) };+ // The canvas the composer binds (its trained size, comfy.ts workflowCanvas); a crop after it makes the saved picture smaller.+ const { width, height } = workflowCanvas(manifest, shape, req.params?.resolution ?? model?.defaults?.resolution);+ return { width, height };}if (!src) return null;let size: Size = { ...src };diff --git a/src/server/storage.ts b/src/server/storage.tsindex efa17fe5..7ecea8c2 100644--- a/src/server/storage.ts+++ b/src/server/storage.ts@@ -264,6 +264,25 @@ export function deleteAsset(id: string): void {db().prepare("DELETE FROM assets WHERE id = ?").run(id);}+/**+ * A stored file's bytes replaced in place (same id, path, address and type), its size recorded again: a run's result the+ * server finishes before the run is done (a crop to the aspect ratio asked). Written beside it first, then moved over it.+ */+export function rewriteAsset(id: string, data: Buffer): Asset | null {+ const a = getAsset(id);+ if (!a) return null;+ const abs = absolutePath(a.relPath);+ const next = `${abs}.${nanoid(6)}.part`;+ try {+ fs.writeFileSync(next, data);+ fs.renameSync(next, abs);+ } finally {+ fs.rmSync(next, { force: true });+ }+ db().prepare("UPDATE assets SET size = ? WHERE id = ?").run(data.length, id);+ return { ...a, size: data.length };+}+/** Resolve a relative path inside FILES_DIR, refusing traversal. */export function absolutePath(relPath: string): string {const abs = path.resolve(FILES_DIR, relPath);diff --git a/tests/open-krea-2.test.ts b/tests/open-krea-2.test.tsindex dc8fa623..9e985447 100644--- a/tests/open-krea-2.test.ts+++ b/tests/open-krea-2.test.ts@@ -136,8 +136,8 @@ describe("Krea 2 graphs", () => {expect(wf["85"].inputs).toMatchObject({ prompt: "", image: ["72", 0], image_b: ["90", 0] });expect(wf["79"].inputs).toMatchObject({ source_latent: ["73", 0], source_latent_b: ["92", 0], source_image: ["72", 0], source_image_b: ["90", 0], target_latent: ["82", 0], ref_boost: 4, ref_boost_a: 1, fit_mode: "fit" });expect(wf["71"].inputs).toMatchObject({ lora_name: "krea2_general_edit_v2.safetensors", strength_model: 1 });- // "auto" keeps the photo's 4:3 at about 1 MP, on the 16-pixel grid.- expect(wf["82"].inputs).toMatchObject({ width: 1184, height: 880 });+ // "auto" keeps the photo's 4:3 on the 16-pixel grid, its shorter side at Krea 2's least (1024).+ expect(wf["82"].inputs).toMatchObject({ width: 1360, height: 1024 });expect(wf["53"].inputs).toMatchObject({ seed: 7, steps: 8, cfg: 1, sampler_name: "euler", scheduler: "simple" });const tall = await prepare("krea2-edit-general", { prompt: "x", images: ["tall.png"], aspectRatio: "auto", resolution: "1K" }, "edit");expect((tall["82"].inputs.width as number) < (tall["82"].inputs.height as number)).toBe(true);diff --git a/tests/open-qwen-image-21.test.ts b/tests/open-qwen-image-21.test.tsindex 9d1e6180..aa07b4a3 100644--- a/tests/open-qwen-image-21.test.ts+++ b/tests/open-qwen-image-21.test.ts@@ -119,9 +119,9 @@ describe("Qwen-Image 2.1 graphs as Fuobe sends them", () => {expect(ofClass(wf, "UNETLoader")[0][1].inputs.unet_name).toBe("qwen_image_2.1_int8_convrot.safetensors");expect(ofClass(wf, "CLIPLoader")[0][1].inputs).toMatchObject({ clip_name: "qwen3vl_8b_int8_convrot.safetensors", type: "qwen_image" });expect(savedFrom(wf, manifest)).toBe("SplitImageWithAlpha");- // 2K in 16:9 is 2720x1536 on the grid, kept within 2048 in its shape.+ // 2K in 16:9 is its native 2752x1536 (the trained sizes in the manifest).const wide = await prepare("qwen-image-21-t2i", { prompt: "x", aspectRatio: "16:9", resolution: "2K" }, "t2i");- expect([at(wide.workflow, wide.manifest, "width")[0], at(wide.workflow, wide.manifest, "height")[0]]).toEqual([2048, 1152]);+ expect([at(wide.workflow, wide.manifest, "width")[0], at(wide.workflow, wide.manifest, "height")[0]]).toEqual([2752, 1536]);const tall = await prepare("qwen-image-21-t2i", { prompt: "x", aspectRatio: "3:4", resolution: "1.5K" }, "t2i");const [w, h] = [Number(at(tall.workflow, tall.manifest, "width")[0]), Number(at(tall.workflow, tall.manifest, "height")[0])];expect([w % 32, h % 32]).toEqual([0, 0]);diff --git a/tests/trained-sizes-run.test.ts b/tests/trained-sizes-run.test.tsnew file mode 100644index 00000000..57a78972--- /dev/null+++ b/tests/trained-sizes-run.test.ts@@ -0,0 +1,73 @@+import fs from "node:fs";+import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";+import type { Generation } from "@/lib/catalog/types";+import { startFakeComfy, type FakeComfy } from "./helpers/fake-comfy-runner";+import { tempDir } from "./helpers/temp-dir";++// A run on a model with trained sizes (comfy.ts workflowCanvas) on a real run path: the graph gets the trained canvas, the+// run records the centre to keep (meta.cropTo), and the saved picture is cropped to the shape asked. A model without+// sizes, and a shape the model is trained at, save the picture as made.+vi.setConfig({ testTimeout: 120_000 });++const dir = tempDir("fuobe-trained-run-");+process.env.FUOBE_DATA_DIR = dir;+delete process.env.FUOBE_PASSWORD;+delete process.env.COMFYUI_WHERE;++const fake: FakeComfy = await startFakeComfy({ output: "image", delayMs: 100 });+process.env.COMFYUI_URL = fake.url;++const gens = await import("@/server/generations");+const { db } = await import("@/server/db");+const { setSetting } = await import("@/server/settings");+const { absolutePath, getAsset } = await import("@/server/storage");+const sharp = (await import("sharp")).default;++beforeAll(() => setSetting("demoMode", "off"));+afterAll(async () => {+ await fake.close();+});++type Graph = Record<string, { class_type: string; inputs: Record<string, unknown> }>;+const graphs = () => fake.log.filter((e) => e.path === "/prompt" && e.prompt).map((e) => e.prompt as Graph);+const meta = (id: string) => JSON.parse((db().prepare("SELECT external_meta_json AS m FROM generations WHERE id = ?").get(id) as { m: string | null }).m ?? "{}");++async function settle(id: string, ms = 60_000): Promise<Generation> {+ const end = Date.now() + ms;+ for (;;) {+ const g = gens.getGeneration(id)!;+ if (["succeeded", "failed", "canceled"].includes(g.status)) return g;+ if (Date.now() > end) throw new Error(`timed out: ${g.status} ${g.message ?? ""}`);+ await new Promise((r) => setTimeout(r, 150));+ }+}++/** One run of `modelId` at a shape and tier: the canvas its graph got, what it kept to crop, and the saved picture's size. */+async function run(modelId: string, aspectRatio: string, resolution: string) {+ const before = graphs().length;+ const [g] = gens.createGenerations({ feature: "image", modelId, prompt: "a lighthouse at dusk", params: { aspectRatio, resolution } });+ const done = await settle(g.id);+ expect(done.status, done.error ?? "").toBe("succeeded");+ const latent = Object.values(graphs().slice(before)[0]).find((n) => typeof n.inputs.width === "number" && typeof n.inputs.height === "number")!;+ const asset = getAsset(done.outputs[0].assetId!)!;+ const saved = await sharp(fs.readFileSync(absolutePath(asset.relPath))).metadata();+ return { canvas: { width: latent.inputs.width, height: latent.inputs.height }, cropTo: meta(g.id).cropTo, saved: { width: saved.width, height: saved.height } };+}++describe("a run on a model with trained sizes keeps the shape asked", () => {+ it("Krea 2 Turbo at 21:9: renders 2048 × 1024 and saves the picture cropped to 21:9", async () => {+ const r = await run("oss-krea2-turbo", "21:9", "1K");+ expect(r.canvas).toEqual({ width: 2048, height: 1024 });+ expect(r.cropTo).toEqual({ width: 2048, height: 878 });+ // The stand-in ComfyUI answers a 2 × 2 picture: its centre at 21:9 is 2 × 1.+ expect(r.saved).toEqual({ width: 2, height: 1 });+ });++ it("a shape the model is trained at, and a model without sizes, save the picture as made", async () => {+ const square = await run("oss-krea2-turbo", "1:1", "1K");+ expect(square).toMatchObject({ canvas: { width: 1024, height: 1024 }, cropTo: undefined, saved: { width: 2, height: 2 } });+ const plain = await run("oss-z-image-turbo", "21:9", "1K");+ expect(plain.cropTo).toBeUndefined();+ expect(plain.saved).toEqual({ width: 2, height: 2 });+ });+});diff --git a/tests/trained-sizes.test.ts b/tests/trained-sizes.test.tsnew file mode 100644index 00000000..11cab296--- /dev/null+++ b/tests/trained-sizes.test.ts@@ -0,0 +1,318 @@+import fs from "node:fs";+import path from "node:path";+import { describe, expect, it } from "vitest";+import type { GenInput, Operation } from "@/lib/catalog/types";+import type { Manifest, ManifestWorkflow } from "@/lib/comfy";+import { tempDir } from "./helpers/temp-dir";++/**+ * Trained canvases (a workflow's manifest `sizes`, comfy.ts workflowCanvas): a model with a table renders the trained size+ * nearest the shape asked, a tier past its range takes its nearest trained size, and a result whose shape isn't the one+ * asked is cropped to it once saved (crop-picture.ts cropSavedToRatio). The composer, the run's size for limits and+ * prices, and the saved picture agree; a workflow without `sizes` renders what it always did.+ */+const dir = tempDir("fuobe-trained-sizes-");+process.env.FUOBE_DATA_DIR = dir;+process.env.COMFYUI_URL = "http://127.0.0.1:9";++const { computeDimensions, cropToRatio, trainedDimensions, workflowCanvas } = await import("@/lib/comfy");+const { prepareWorkflow } = await import("@/server/providers/comfyui");+const { requestMegapixels } = await import("@/server/hosted");+const { getModel } = await import("@/lib/catalog");+const { SPEC } = await import("../scripts/comfy/library.spec.mjs");+const { absolutePath, getAsset, saveFile } = await import("@/server/storage");+const { askedCrop, cropSavedToRatio } = await import("@/server/crop-picture");+const sharp = (await import("sharp")).default;++const manifest = JSON.parse(fs.readFileSync(path.join(process.cwd(), "workflows/comfyui/manifest.json"), "utf8")) as Manifest;+const entry = (id: string) => manifest.workflows.find((w) => w.id === id)!;+const RATIOS = ["1:1", "4:3", "3:4", "16:9", "9:16", "3:2", "2:3", "21:9", "5:4", "4:5"];+const TIERS = [undefined, "0.5K", "1K", "1MP", "1.5K", "2K", "4K"];+const ratioOf = (r: string) => r.split(":").map(Number).reduce((a, b) => a / b);++/** [width, height] it renders, then the crop it keeps (none: the canvas has the shape asked). */+type Want = [number, number] | [number, number, number, number];+const canvas = (id: string, ratio: string, tier?: string): Want => {+ const c = workflowCanvas(entry(id), ratio, tier);+ return c.crop ? [c.width, c.height, c.crop.width, c.crop.height] : [c.width, c.height];+};++const QWEN21 = ["qwen-image-21-t2i", "qwen-image-21-t2i-small", "qwen-image-21-t2i-draft", "qwen-image-21-t2i-fast", "qwen-image-21-t2i-details"];+const KREA2 = ["krea2-realism-t2i", "krea2-turbo-t2i", "krea2-edit-general", "krea2-edit-identity", "style-ref-krea2"];+const FLUX1 = ["flux1-dev-t2i", "flux1-krea-dev-t2i", "flux1-schnell-t2i", "style-ref-uso-flux1"];++describe("trained size tables in the manifest", () => {+ const tabled = manifest.workflows.filter((w) => w.sizes);++ it("are the models with verified sizes, and only those", () => {+ expect(tabled.map((w) => w.id).sort()).toEqual(+ [...QWEN21, ...KREA2, ...FLUX1, "qwen-image-2512-t2i", "qwen-image-2512-t2i-lightning", "hidream-i1-dev-t2i", "sdxl-t2i", "minimax-h3-image-t2i"].sort(),+ );+ // No verified guidance yet: unchanged.+ for (const id of ["flux3-klein-t2i", "style-ref-flux2-klein-4b", "style-ref-qwen-edit-2511", "z-image-turbo-t2i", "moss-image-t2i", "ideogram4-t2i", "flux2-dev-t2i"]) {+ expect(entry(id)?.sizes, id).toBeUndefined();+ }+ });++ it.each(tabled.map((w) => [w.id, w] as const))("%s: each size on the graph's grid and inside its limits, both orientations, as library.spec says", (id, w) => {+ const spec = (SPEC as { id: string; sizes?: unknown }[]).find((s) => s.id === id);+ expect(w.sizes).toEqual(spec?.sizes);+ expect(w.bindings.width && w.bindings.height, id).toBeTruthy();+ const m = Number(w.limits?.dimensionMultiple ?? 16);+ for (const [tier, list] of Object.entries(w.sizes!.tiers ?? {})) {+ expect(list.length, tier).toBeGreaterThan(0);+ for (const [width, height] of list) {+ expect(width % m || height % m, `${id} ${tier} ${width}x${height}`).toBe(0);+ expect(width <= Number(w.limits?.maxWidth ?? Infinity) && height <= Number(w.limits?.maxHeight ?? Infinity), `${id} ${tier} ${width}x${height}`).toBe(true);+ expect(list.some(([a, b]) => a === height && b === width), `${id} ${tier} ${height}x${width}`).toBe(true);+ }+ }+ const s = w.sizes!;+ if (s.minSide && s.maxSide) expect(s.minSide).toBeLessThan(s.maxSide);+ });+});++describe("the canvas each model renders", () => {+ it("Qwen-Image 2.1 (every route of its text to image): its native shapes at about 1, 2.3 and 4 MP; 21:9 and 5:4 render the nearest and crop", () => {+ for (const id of QWEN21) {+ expect(entry(id).limits).toMatchObject({ maxWidth: 2752, maxHeight: 2752, dimensionMultiple: 32 });+ expect(["1:1", "16:9", "21:9", "9:16", "4:3", "3:2", "5:4"].map((r) => canvas(id, r, "2K")), id).toEqual([+ [2048, 2048],+ [2752, 1536],+ [2752, 1536, 2752, 1179],+ [1536, 2752],+ [2400, 1792],+ [2528, 1696],+ [2400, 1792, 2240, 1792],+ ]);+ expect(["1:1", "16:9", "21:9", "4:3", "3:2"].map((r) => canvas(id, r, "1.5K")), id).toEqual([[1536, 1536], [2048, 1152], [2048, 1152, 2048, 878], [1760, 1312], [1856, 1248]]);+ expect(["1:1", "16:9", "21:9", "4:3", "3:2"].map((r) => canvas(id, r, "1K")), id).toEqual([[1024, 1024], [1376, 768], [1376, 768, 1376, 590], [1152, 864], [1248, 832]]);+ }+ // Its default (1K, 1:1) is what it always was.+ expect(getModel("oss-qwen-image-21")!.defaults).toMatchObject({ aspectRatio: "1:1", resolution: "1K" });+ expect(canvas("qwen-image-21-t2i", "1:1", "1K")).toEqual([1024, 1024]);+ });++ it("Qwen-Image 2512 and its Lightning: the model card's sizes at 1K, and 1.5K clamps to them", () => {+ for (const id of ["qwen-image-2512-t2i", "qwen-image-2512-t2i-lightning"]) {+ for (const tier of ["1K", "1.5K", undefined]) {+ expect(["1:1", "16:9", "9:16", "4:3", "3:2", "21:9"].map((r) => canvas(id, r, tier)), `${id} ${tier}`).toEqual([+ [1328, 1328],+ [1664, 928],+ [928, 1664],+ [1472, 1104],+ [1584, 1056],+ [1664, 928, 1664, 713],+ ]);+ }+ }+ });++ it("HiDream I1 and SDXL: their 1 MP buckets; SDXL's shapes are near the ratios asked, so most crop a little", () => {+ expect(["1:1", "16:9", "4:3", "3:2", "21:9"].map((r) => canvas("hidream-i1-dev-t2i", r))).toEqual([[1024, 1024], [1360, 768], [1168, 880], [1248, 832], [1360, 768, 1360, 583]]);+ expect(["1:1", "16:9", "9:16", "4:3", "5:4", "3:2", "21:9"].map((r) => canvas("sdxl-t2i", r))).toEqual([+ [1024, 1024],+ [1344, 768, 1344, 756],+ [768, 1344, 756, 1344],+ [1152, 896, 1152, 864],+ [1152, 896, 1120, 896],+ [1216, 832, 1216, 811],+ [1536, 640, 1493, 640],+ ]);+ });++ it("MiniMax H3 Image: 2K and 4K as before for the shapes its card lists; others render the nearest and crop; its default stays 2K", () => {+ const before = (r: string, tier: string) => computeDimensions(r, tier, { width: 2048, height: 2048 }, 32);+ for (const tier of ["2K", "4K"]) {+ for (const r of ["1:1", "4:3", "3:4", "3:2", "2:3", "16:9", "9:16", "21:9"]) {+ const { width, height } = before(r, tier);+ expect(canvas("minimax-h3-image-t2i", r, tier), `${tier} ${r}`).toEqual([width, height]);+ }+ }+ expect(["1:1", "16:9", "21:9"].map((r) => canvas("minimax-h3-image-t2i", r, "4K"))).toEqual([[4096, 4096], [5472, 3072], [6272, 2688]]);+ expect(canvas("minimax-h3-image-t2i", "5:4", "4K")).toEqual([4736, 3552, 4440, 3552]);+ expect(canvas("minimax-h3-image-t2i", "4:5", "2K")).toEqual([1760, 2368, 1760, 2200]);+ // A tier it isn't trained at takes the nearest one it is.+ expect(canvas("minimax-h3-image-t2i", "1:1", "1K")).toEqual([2048, 2048]);+ expect(getModel("oss-minimax-h3-image")!.defaults).toMatchObject({ resolution: "2K" });+ });++ it("Krea 2: the shorter side never under 1024 and the longer never past 2048; 21:9 renders 2:1 and crops", () => {+ for (const id of KREA2) {+ expect(["1:1", "16:9", "9:16", "21:9", "4:3"].map((r) => canvas(id, r, "1K")), id).toEqual([[1024, 1024], [1824, 1024], [1024, 1824], [2048, 1024, 2048, 878], [1360, 1024]]);+ expect(["1:1", "16:9", "21:9"].map((r) => canvas(id, r, "1.5K")), id).toEqual([[1536, 1536], [2048, 1152], [2048, 1024, 2048, 878]]);+ expect(["1:1", "16:9", "21:9"].map((r) => canvas(id, r, "2K")), id).toEqual([[2048, 2048], [2048, 1152], [2048, 1024, 2048, 878]]);+ for (const r of RATIOS) {+ for (const tier of TIERS) {+ const c = workflowCanvas(entry(id), r, tier);+ expect(Math.min(c.width, c.height), `${id} ${r} ${tier}`).toBeGreaterThanOrEqual(1024);+ expect(Math.max(c.width, c.height), `${id} ${r} ${tier}`).toBeLessThanOrEqual(2048);+ }+ }+ }+ });++ it("FLUX.1: as before up to about 2 MP; 1.5K clamps to its 2 MP sizes", () => {+ for (const id of FLUX1) {+ const d = entry(id).defaults;+ for (const r of RATIOS) {+ const { width, height } = computeDimensions(r, "1K", { width: Number(d.width), height: Number(d.height) }, 16);+ expect(canvas(id, r, "1K"), `${id} ${r}`).toEqual([width, height]);+ }+ expect(["1:1", "16:9", "9:16", "3:2"].map((r) => canvas(id, r, "1.5K")), id).toEqual([[1408, 1408], [1888, 1056], [1056, 1888], [1728, 1152]]);+ // 2 MP at 21:9 is 2160 wide, past the graph's 2048: scaled down whole, then cropped back to 21:9.+ expect(canvas(id, "21:9", "1.5K")).toEqual([2048, 864, 2016, 864]);+ for (const r of RATIOS) {+ const c = workflowCanvas(entry(id), r, "1.5K");+ expect(c.width * c.height, `${id} ${r}`).toBeLessThanOrEqual(2.02e6);+ }+ }+ });++ it("a workflow without sizes renders exactly what it did before, never cropped", () => {+ const before = (w: ManifestWorkflow, r: string | undefined, tier: string | undefined) => {+ const m = Number(w.limits?.dimensionMultiple ?? 16);+ const dims = computeDimensions(r, tier, { width: Number(w.defaults?.width ?? 1024), height: Number(w.defaults?.height ?? 1024) }, m);+ const k = Math.min(1, Number(w.limits?.maxWidth ?? Infinity) / dims.width, Number(w.limits?.maxHeight ?? Infinity) / dims.height);+ return { width: Math.max(m, Math.floor((dims.width * k) / m) * m), height: Math.max(m, Math.floor((dims.height * k) / m) * m) };+ };+ const plain = manifest.workflows.filter((w) => !w.sizes && (w.bindings.width || w.bindings.height));+ expect(plain.length).toBeGreaterThan(50);+ for (const w of plain) {+ for (const r of [undefined, "1:1", "16:9", "9:16", "21:9", "5:4", "2.39:1", "1920:1080"]) {+ for (const tier of [...TIERS, "720p", "1080p"]) expect(workflowCanvas(w, r, tier), `${w.id} ${r} ${tier}`).toEqual(before(w, r, tier));+ }+ }+ });+});++describe("nearest shape and crop math", () => {+ it("the crop is the largest centre of the canvas with the ratio asked; within 1% is that ratio already", () => {+ expect(cropToRatio(2752, 1536, 21 / 9)).toEqual({ width: 2752, height: 1179 });+ expect(cropToRatio(1536, 2752, 9 / 21)).toEqual({ width: 1179, height: 2752 });+ expect(cropToRatio(2400, 1792, 5 / 4)).toEqual({ width: 2240, height: 1792 });+ expect(cropToRatio(2048, 1024, 21 / 9)).toEqual({ width: 2048, height: 878 });+ // The grid's own rounding is no crop: 1376 × 768 is 16:9 within 0.8%.+ expect(cropToRatio(1376, 768, 16 / 9)).toBeUndefined();+ expect(cropToRatio(2048, 2048, 1)).toBeUndefined();+ expect(cropToRatio(0, 10, 1)).toBeUndefined();+ // What a crop costs: the pixels outside the centre kept.+ const cost = (w: number, h: number, r: number) => {+ const c = cropToRatio(w, h, r)!;+ return Math.round((1 - (c.width * c.height) / (w * h)) * 1000) / 10;+ };+ expect(cost(2752, 1536, 21 / 9)).toBe(23.2);+ expect(cost(2048, 1024, 21 / 9)).toBe(14.3);+ expect(cost(4736, 3552, 5 / 4)).toBe(6.3);+ expect(cost(1344, 768, 16 / 9)).toBe(1.6);+ });++ it("picks the listed size of the nearest shape, and the listed tier nearest by area when the one asked isn't listed", () => {+ const sizes = { tiers: { "1K": [[1024, 1024], [1344, 768], [768, 1344]] as [number, number][], "2K": [[2048, 2048], [2688, 1536], [1536, 2688]] as [number, number][] } };+ const d = { width: 1024, height: 1024 };+ expect(trainedDimensions(sizes, 16 / 9, "1K", d)).toEqual({ width: 1344, height: 768 });+ expect(trainedDimensions(sizes, 21 / 9, "2K", d)).toEqual({ width: 2688, height: 1536 });+ expect(trainedDimensions(sizes, 9 / 16, "2K", d)).toEqual({ width: 1536, height: 2688 });+ expect(trainedDimensions(sizes, 5 / 4, "1K", d)).toEqual({ width: 1024, height: 1024 });+ expect(trainedDimensions(sizes, 4 / 3, "1K", d)).toEqual({ width: 1344, height: 768 });+ expect(trainedDimensions(sizes, 1, "1.5K", d)).toEqual({ width: 2048, height: 2048 });+ expect(trainedDimensions(sizes, 1, "0.5K", d)).toEqual({ width: 1024, height: 1024 });+ expect(trainedDimensions(sizes, 1, "4K", d)).toEqual({ width: 2048, height: 2048 });+ // No tier: the workflow's default area.+ expect(trainedDimensions(sizes, 1, undefined, { width: 2048, height: 2048 })).toEqual({ width: 2048, height: 2048 });+ // A range the canvas is inside already, or no sizes: computeDimensions decides.+ expect(trainedDimensions({ minSide: 512, maxSide: 4096 }, 16 / 9, "1K", d)).toBeNull();+ expect(trainedDimensions({ maxMegapixels: 2 }, 1, "1K", d)).toBeNull();+ expect(trainedDimensions(undefined, 1, "1K", d)).toBeNull();+ });+});++describe("every caller agrees on the canvas", () => {+ const MEDIA: Record<string, { width: number; height: number }> = { "wide.png": { width: 3000, height: 1000 } };+ const prepare = (id: string, input: GenInput, op: Operation) =>+ prepareWorkflow(id, { seed: 7, prompt: "a lighthouse at dusk", ...input }, { generationId: "g", op, upload: async (_d, _t, name) => `up_${name}`, media: ((name: string) => MEDIA[name]) as never });+ const bound = (w: ManifestWorkflow, wf: Record<string, { inputs: Record<string, unknown> }>) => ({+ width: wf[w.bindings.width![0].node].inputs[w.bindings.width![0].input],+ height: wf[w.bindings.height![0].node].inputs[w.bindings.height![0].input],+ });+ const CASES: [string, string, string, string | undefined][] = [+ ["oss-qwen-image-21", "qwen-image-21-t2i", "21:9", "2K"],+ ["oss-qwen-image-21", "qwen-image-21-t2i", "16:9", "1.5K"],+ ["oss-qwen-image", "qwen-image-2512-t2i", "21:9", "1.5K"],+ ["oss-hidream", "hidream-i1-dev-t2i", "16:9", undefined],+ ["oss-sdxl", "sdxl-t2i", "4:3", undefined],+ ["oss-minimax-h3-image", "minimax-h3-image-t2i", "5:4", "4K"],+ ["oss-krea2-realism", "krea2-realism-t2i", "21:9", "1.5K"],+ ["oss-flux1-dev", "flux1-dev-t2i", "1:1", "1.5K"],+ ["oss-z-image-turbo", "z-image-turbo-t2i", "21:9", "1.5K"],+ ];++ it.each(CASES)("%s (%s) at %s %s: the graph, the run's size and the crop it saves", async (modelId, id, aspectRatio, resolution) => {+ const model = getModel(modelId);+ expect(model?.routes.some((r) => r.endpoint === id), `${modelId} → ${id}`).toBe(true);+ const want = workflowCanvas(entry(id), aspectRatio, resolution);+ const p = await prepare(id, { aspectRatio, resolution }, "t2i");+ expect(bound(entry(id), p.workflow as never)).toEqual({ width: want.width, height: want.height });+ expect(p.meta.cropTo).toEqual(want.crop);+ expect(p.size.megapixels).toBeCloseTo((want.width * want.height) / 1e6, 2);+ const req = { modelId, feature: "image", prompt: "x", params: { aspectRatio, resolution } };+ expect(requestMegapixels(req as never, "image", modelId, id)).toBe(Math.round((want.width * want.height) / 10_000) / 100);+ if (entry(id).sizes) expect(want.crop ?? null, "a table that has this shape crops nothing").toEqual(cropToRatio(want.width, want.height, ratioOf(aspectRatio)) ?? null);+ else expect(want.crop).toBeUndefined();+ });++ it("a canvas the request names is rendered as named, never cropped; 'auto' on Krea 2 Edit keeps the photo's shape", async () => {+ const named = await prepare("qwen-image-21-t2i", { aspectRatio: "21:9", resolution: "2K", extra: { width: 1280, height: 720 } }, "t2i");+ expect(bound(entry("qwen-image-21-t2i"), named.workflow as never)).toEqual({ width: 1280, height: 736 });+ expect(named.meta.cropTo).toBeUndefined();+ const edit = await prepare("krea2-edit-general", { aspectRatio: "auto", resolution: "1K", images: ["wide.png"] }, "edit");+ // 3:1 inside 1024-2048 renders 2048 × 1024 and keeps the photo's 3:1.+ expect(bound(entry("krea2-edit-general"), edit.workflow as never)).toEqual({ width: 2048, height: 1024 });+ expect(edit.meta.cropTo).toEqual({ width: 2048, height: 683 });+ });+});++describe("the saved picture is cropped to the shape asked", () => {+ const save = async (width: number, height: number, format: "png" | "jpeg") => {+ const img = sharp({ create: { width, height, channels: 3, background: "#468" } });+ const data = await (format === "png" ? img.png() : img.jpeg()).toBuffer();+ const asset = saveFile({ data, contentType: `image/${format}`, source: "generation", generationId: "g" });+ return { url: asset.url, kind: "image" as const, contentType: asset.contentType, assetId: asset.id };+ };+ const onDisk = async (id: string) => {+ const a = getAsset(id)!;+ const meta = await sharp(fs.readFileSync(absolutePath(a.relPath))).metadata();+ return { width: meta.width, height: meta.height, format: meta.format, size: a.size, bytes: fs.statSync(absolutePath(a.relPath)).size };+ };++ it("crops a PNG and a JPEG in place, centred, in their own format; the file's recorded size follows", async () => {+ const png = await save(2752, 1536, "png");+ const out = await cropSavedToRatio(png, { width: 2752, height: 1179 });+ expect(out).toEqual(png);+ const now = await onDisk(png.assetId);+ expect(now).toMatchObject({ width: 2752, height: 1179, format: "png" });+ expect(now.size).toBe(now.bytes);+ const jpeg = await save(2400, 1792, "jpeg");+ await cropSavedToRatio(jpeg, { width: 2240, height: 1792 });+ expect(await onDisk(jpeg.assetId)).toMatchObject({ width: 2240, height: 1792, format: "jpeg" });+ });++ it("leaves a picture that has the shape already, a video and a file that's gone as they are", async () => {+ const square = await save(1024, 1024, "png");+ const before = fs.readFileSync(absolutePath(getAsset(square.assetId)!.relPath));+ await cropSavedToRatio(square, { width: 1024, height: 1024 });+ expect(fs.readFileSync(absolutePath(getAsset(square.assetId)!.relPath)).equals(before)).toBe(true);+ const clip = { url: "/api/files/x.mp4", kind: "video" as const, assetId: square.assetId };+ expect(await cropSavedToRatio(clip, { width: 21, height: 9 })).toBe(clip);+ const gone = { url: "/api/files/y.png", kind: "image" as const, assetId: "nope" };+ expect(await cropSavedToRatio(gone, { width: 21, height: 9 })).toBe(gone);+ });++ it("reads the crop a run's composer named, and nothing else", () => {+ expect(askedCrop({ cropTo: { width: 2752, height: 1179 } })).toEqual({ width: 2752, height: 1179 });+ expect(askedCrop({ cropTo: { width: "2752", height: 1179 } })).toBeUndefined();+ expect(askedCrop({ cropTo: { width: 0, height: 1179 } })).toBeUndefined();+ expect(askedCrop({})).toBeUndefined();+ expect(askedCrop(undefined)).toBeUndefined();+ });+});diff --git a/workflows/comfyui/manifest.json b/workflows/comfyui/manifest.jsonindex f741724a..69ea30d2 100644--- a/workflows/comfyui/manifest.json+++ b/workflows/comfyui/manifest.json@@ -73,6 +73,9 @@"maxHeight": 2048,"dimensionMultiple": 16},+ "sizes": {+ "maxMegapixels": 2+ },"models": [{"file": "ae.safetensors",@@ -178,6 +181,9 @@"maxHeight": 2048,"dimensionMultiple": 16},+ "sizes": {+ "maxMegapixels": 2+ },"models": [{"file": "clip_l.safetensors",@@ -273,6 +279,9 @@"maxHeight": 2048,"dimensionMultiple": 16},+ "sizes": {+ "maxMegapixels": 2+ },"models": [{"file": "flux1-schnell.safetensors",@@ -824,6 +833,40 @@"maxHeight": 2048,"dimensionMultiple": 16},+ "sizes": {+ "tiers": {+ "1K": [+ [+ 1328,+ 1328+ ],+ [+ 1664,+ 928+ ],+ [+ 928,+ 1664+ ],+ [+ 1472,+ 1104+ ],+ [+ 1104,+ 1472+ ],+ [+ 1584,+ 1056+ ],+ [+ 1056,+ 1584+ ]+ ]+ }+ },"models": [{"file": "qwen_2.5_vl_7b_fp8_scaled.safetensors",@@ -929,6 +972,40 @@"maxHeight": 2048,"dimensionMultiple": 16},+ "sizes": {+ "tiers": {+ "1K": [+ [+ 1328,+ 1328+ ],+ [+ 1664,+ 928+ ],+ [+ 928,+ 1664+ ],+ [+ 1472,+ 1104+ ],+ [+ 1104,+ 1472+ ],+ [+ 1584,+ 1056+ ],+ [+ 1056,+ 1584+ ]+ ]+ }+ },"models": [{"file": "qwen_2.5_vl_7b_fp8_scaled.safetensors",@@ -1139,6 +1216,40 @@"maxHeight": 2048,"dimensionMultiple": 16},+ "sizes": {+ "tiers": {+ "1K": [+ [+ 1024,+ 1024+ ],+ [+ 1360,+ 768+ ],+ [+ 768,+ 1360+ ],+ [+ 1168,+ 880+ ],+ [+ 880,+ 1168+ ],+ [+ 1248,+ 832+ ],+ [+ 832,+ 1248+ ]+ ]+ }+ },"models": [{"file": "clip_l_hidream.safetensors",@@ -1255,6 +1366,48 @@"maxHeight": 1536,"dimensionMultiple": 8},+ "sizes": {+ "tiers": {+ "1K": [+ [+ 1024,+ 1024+ ],+ [+ 1152,+ 896+ ],+ [+ 896,+ 1152+ ],+ [+ 1216,+ 832+ ],+ [+ 832,+ 1216+ ],+ [+ 1344,+ 768+ ],+ [+ 768,+ 1344+ ],+ [+ 1536,+ 640+ ],+ [+ 640,+ 1536+ ]+ ]+ }+ },"models": [{"file": "sd_xl_base_1.0.safetensors",@@ -1873,6 +2026,86 @@"maxHeight": 6272,"dimensionMultiple": 32},+ "sizes": {+ "tiers": {+ "2K": [+ [+ 2048,+ 2048+ ],+ [+ 2368,+ 1760+ ],+ [+ 1760,+ 2368+ ],+ [+ 2496,+ 1664+ ],+ [+ 1664,+ 2496+ ],+ [+ 2720,+ 1536+ ],+ [+ 1536,+ 2720+ ],+ [+ 3136,+ 1344+ ],+ [+ 1344,+ 3136+ ]+ ],+ "4K": [+ [+ 4096,+ 4096+ ],+ [+ 4736,+ 3552+ ],+ [+ 3552,+ 4736+ ],+ [+ 5024,+ 3360+ ],+ [+ 3360,+ 5024+ ],+ [+ 5472,+ 3072+ ],+ [+ 3072,+ 5472+ ],+ [+ 6272,+ 2688+ ],+ [+ 2688,+ 6272+ ]+ ]+ }+ },"models": [{"file": "minimax_h3_image_pruned_int8_convrot.safetensors",@@ -13498,6 +13731,10 @@"maxHeight": 2048,"dimensionMultiple": 16},+ "sizes": {+ "minSide": 1024,+ "maxSide": 2048+ },"models": [{"file": "krea2_turbo_int8_convrot.safetensors",@@ -13609,6 +13846,9 @@"maxHeight": 2048,"dimensionMultiple": 16},+ "sizes": {+ "maxMegapixels": 2+ },"models": [{"file": "flux1-dev-fp8.safetensors",@@ -13934,10 +14174,104 @@"steps": 25},"limits": {- "maxWidth": 2048,- "maxHeight": 2048,+ "maxWidth": 2752,+ "maxHeight": 2752,"dimensionMultiple": 32},+ "sizes": {+ "tiers": {+ "1K": [+ [+ 1024,+ 1024+ ],+ [+ 1152,+ 864+ ],+ [+ 864,+ 1152+ ],+ [+ 1248,+ 832+ ],+ [+ 832,+ 1248+ ],+ [+ 1376,+ 768+ ],+ [+ 768,+ 1376+ ]+ ],+ "1.5K": [+ [+ 1536,+ 1536+ ],+ [+ 1760,+ 1312+ ],+ [+ 1312,+ 1760+ ],+ [+ 1856,+ 1248+ ],+ [+ 1248,+ 1856+ ],+ [+ 2048,+ 1152+ ],+ [+ 1152,+ 2048+ ]+ ],+ "2K": [+ [+ 2048,+ 2048+ ],+ [+ 2400,+ 1792+ ],+ [+ 1792,+ 2400+ ],+ [+ 2528,+ 1696+ ],+ [+ 1696,+ 2528+ ],+ [+ 2752,+ 1536+ ],+ [+ 1536,+ 2752+ ]+ ]+ }+ },"models": [{"file": "qwen_image_2.1_int8_convrot.safetensors",@@ -13969,7 +14303,7 @@"vramGb": 20,"license": "Qwen Research License Agreement (Qwen-Image 2.1): NON-COMMERCIAL, research and evaluation only; Texture-Fix VAE (madebyollin @ 9a10df81, optional: Options → Decoder Clean): Qwen Research License (card: license_name qwen-research)","validated": true,- "notes": "The Qwen-Image 2.1 text-to-image workflow, its subgraph flattened: int8 model, Qwen3-VL 8B int8 text encoder (type qwen_image), TextEncodeQwenImage21 (no negative, resolution 1024, no images), EmptyLatentImage, KSampler 25 steps, cfg 1, euler, simple, denoise 1. Removed: the ResolutionSelector (width/height bind the latent, multiples of 32, native up to 2048x2048) and the SaveImageAdvanced (SaveImage after SplitImageWithAlpha, as the Qwen 2.1 VAE decodes four channels). cfg 1: no negative prompt. Options → Decoder \"Clean\" sets vae to the Texture-Fix VAE (madebyollin, a finetuned Qwen-Image 2.1 decoder, Qwen Research License; optional file, which the GPU pre-flight asks for when Clean is picked)."+ "notes": "The Qwen-Image 2.1 text-to-image workflow, its subgraph flattened: int8 model, Qwen3-VL 8B int8 text encoder (type qwen_image), TextEncodeQwenImage21 (no negative, resolution 1024, no images), EmptyLatentImage, KSampler 25 steps, cfg 1, euler, simple, denoise 1. Removed: the ResolutionSelector (width/height bind the latent, multiples of 32; its native sizes go up to 2752x1536, listed in sizes) and the SaveImageAdvanced (SaveImage after SplitImageWithAlpha, as the Qwen 2.1 VAE decodes four channels). cfg 1: no negative prompt. Options → Decoder \"Clean\" sets vae to the Texture-Fix VAE (madebyollin, a finetuned Qwen-Image 2.1 decoder, Qwen Research License; optional file, which the GPU pre-flight asks for when Clean is picked)."},{"id": "qwen-image-21-edit",@@ -14836,10 +15170,104 @@"height": 1024},"limits": {- "maxWidth": 2048,- "maxHeight": 2048,+ "maxWidth": 2752,+ "maxHeight": 2752,"dimensionMultiple": 32},+ "sizes": {+ "tiers": {+ "1K": [+ [+ 1024,+ 1024+ ],+ [+ 1152,+ 864+ ],+ [+ 864,+ 1152+ ],+ [+ 1248,+ 832+ ],+ [+ 832,+ 1248+ ],+ [+ 1376,+ 768+ ],+ [+ 768,+ 1376+ ]+ ],+ "1.5K": [+ [+ 1536,+ 1536+ ],+ [+ 1760,+ 1312+ ],+ [+ 1312,+ 1760+ ],+ [+ 1856,+ 1248+ ],+ [+ 1248,+ 1856+ ],+ [+ 2048,+ 1152+ ],+ [+ 1152,+ 2048+ ]+ ],+ "2K": [+ [+ 2048,+ 2048+ ],+ [+ 2400,+ 1792+ ],+ [+ 1792,+ 2400+ ],+ [+ 2528,+ 1696+ ],+ [+ 1696,+ 2528+ ],+ [+ 2752,+ 1536+ ],+ [+ 1536,+ 2752+ ]+ ]+ }+ },"models": [{"file": "qwen_image_2.1_int8_convrot.safetensors",@@ -14940,10 +15368,104 @@"height": 1024},"limits": {- "maxWidth": 2048,- "maxHeight": 2048,+ "maxWidth": 2752,+ "maxHeight": 2752,"dimensionMultiple": 32},+ "sizes": {+ "tiers": {+ "1K": [+ [+ 1024,+ 1024+ ],+ [+ 1152,+ 864+ ],+ [+ 864,+ 1152+ ],+ [+ 1248,+ 832+ ],+ [+ 832,+ 1248+ ],+ [+ 1376,+ 768+ ],+ [+ 768,+ 1376+ ]+ ],+ "1.5K": [+ [+ 1536,+ 1536+ ],+ [+ 1760,+ 1312+ ],+ [+ 1312,+ 1760+ ],+ [+ 1856,+ 1248+ ],+ [+ 1248,+ 1856+ ],+ [+ 2048,+ 1152+ ],+ [+ 1152,+ 2048+ ]+ ],+ "2K": [+ [+ 2048,+ 2048+ ],+ [+ 2400,+ 1792+ ],+ [+ 1792,+ 2400+ ],+ [+ 2528,+ 1696+ ],+ [+ 1696,+ 2528+ ],+ [+ 2752,+ 1536+ ],+ [+ 1536,+ 2752+ ]+ ]+ }+ },"models": [{"file": "qwen_image_2.1_int8_convrot.safetensors",@@ -15038,10 +15560,104 @@"height": 1024},"limits": {- "maxWidth": 2048,- "maxHeight": 2048,+ "maxWidth": 2752,+ "maxHeight": 2752,"dimensionMultiple": 32},+ "sizes": {+ "tiers": {+ "1K": [+ [+ 1024,+ 1024+ ],+ [+ 1152,+ 864+ ],+ [+ 864,+ 1152+ ],+ [+ 1248,+ 832+ ],+ [+ 832,+ 1248+ ],+ [+ 1376,+ 768+ ],+ [+ 768,+ 1376+ ]+ ],+ "1.5K": [+ [+ 1536,+ 1536+ ],+ [+ 1760,+ 1312+ ],+ [+ 1312,+ 1760+ ],+ [+ 1856,+ 1248+ ],+ [+ 1248,+ 1856+ ],+ [+ 2048,+ 1152+ ],+ [+ 1152,+ 2048+ ]+ ],+ "2K": [+ [+ 2048,+ 2048+ ],+ [+ 2400,+ 1792+ ],+ [+ 1792,+ 2400+ ],+ [+ 2528,+ 1696+ ],+ [+ 1696,+ 2528+ ],+ [+ 2752,+ 1536+ ],+ [+ 1536,+ 2752+ ]+ ]+ }+ },"models": [{"file": "qwen_image_2.1_int8_convrot.safetensors",@@ -16192,10 +16808,104 @@"steps": 30},"limits": {- "maxWidth": 2048,- "maxHeight": 2048,+ "maxWidth": 2752,+ "maxHeight": 2752,"dimensionMultiple": 32},+ "sizes": {+ "tiers": {+ "1K": [+ [+ 1024,+ 1024+ ],+ [+ 1152,+ 864+ ],+ [+ 864,+ 1152+ ],+ [+ 1248,+ 832+ ],+ [+ 832,+ 1248+ ],+ [+ 1376,+ 768+ ],+ [+ 768,+ 1376+ ]+ ],+ "1.5K": [+ [+ 1536,+ 1536+ ],+ [+ 1760,+ 1312+ ],+ [+ 1312,+ 1760+ ],+ [+ 1856,+ 1248+ ],+ [+ 1248,+ 1856+ ],+ [+ 2048,+ 1152+ ],+ [+ 1152,+ 2048+ ]+ ],+ "2K": [+ [+ 2048,+ 2048+ ],+ [+ 2400,+ 1792+ ],+ [+ 1792,+ 2400+ ],+ [+ 2528,+ 1696+ ],+ [+ 1696,+ 2528+ ],+ [+ 2752,+ 1536+ ],+ [+ 1536,+ 2752+ ]+ ]+ }+ },"models": [{"file": "qwen_image_2.1_int8_convrot.safetensors",@@ -16775,6 +17485,10 @@"maxHeight": 2048,"dimensionMultiple": 16},+ "sizes": {+ "minSide": 1024,+ "maxSide": 2048+ },"models": [{"file": "krea2_turbo_fp8_scaled.safetensors",@@ -16867,6 +17581,10 @@"maxHeight": 2048,"dimensionMultiple": 16},+ "sizes": {+ "minSide": 1024,+ "maxSide": 2048+ },"models": [{"file": "krea2_turbo_fp8_scaled.safetensors",@@ -16965,6 +17683,10 @@"maxHeight": 2048,"dimensionMultiple": 16},+ "sizes": {+ "minSide": 1024,+ "maxSide": 2048+ },"models": [{"file": "krea2_turbo_fp8_scaled.safetensors",@@ -17074,6 +17796,10 @@"maxHeight": 2048,"dimensionMultiple": 16},+ "sizes": {+ "minSide": 1024,+ "maxSide": 2048+ },"models": [{"file": "krea2_turbo_fp8_scaled.safetensors",