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
Layouts everywhere: drawn ads and posters use the brand's own logo or its name, never a made-up mark
Claudeb1ddfc90d03d
diff --git a/CREDITS.md b/CREDITS.mdindex ceeef5cf..4fa4bec7 100644--- a/CREDITS.md+++ b/CREDITS.md@@ -20,6 +20,7 @@ Some licences ask the app that runs their model to say so.- [BS-RoFormer, copyright (c) 2023 Phil Wang](https://github.com/lucidrains/BS-RoFormer). MIT. For dialogue, music and effects separation.- [Music-Source-Separation-Training, copyright (c) 2024 Roman Solovyev (ZFTurbo)](https://github.com/ZFTurbo/Music-Source-Separation-Training). MIT. For dialogue, music and effects separation.- [TIGER / Look2Hear, copyright (c) 2026 Kai Li](https://github.com/JusperLee/TIGER). MIT. For dialogue, music and effects separation.+- [Adapted from MOSS-Image's prompt-enhancer skill and its layout reference (commit 2b46b1e), copyright OpenMOSS](https://github.com/OpenMOSS/MOSS-Image). Apache-2.0. For the Layout Poster skill and Plan layout.## Open model licencesdiff --git a/src/lib/catalog/marketing.ts b/src/lib/catalog/marketing.tsindex ca44cf24..0b6e9cec 100644--- a/src/lib/catalog/marketing.ts+++ b/src/lib/catalog/marketing.ts@@ -988,7 +988,7 @@ export const DRAWN_WORDS_MODELS: Record<Engine, ModelChoice[]> = {open: [{ id: "oss-moss-image", name: "MOSS-Image", note: "MOSS-Image on your GPU · draws your words in place, free" }],cloud: [{ id: "moss-image", name: "MOSS-Image", note: "MOSS-Image, hosted on fal · draws your words in place" },- { id: "ideogram-4-5", name: "Ideogram 4.5", note: "Draws the exact text in place" },+ { id: "ideogram-4-5", name: "Ideogram 4.5", note: "Draws the exact text in place and keeps your product photo" },{ id: "flux-3", name: "FLUX.3", note: "Draws the text in place and keeps your product photo" },],};diff --git a/src/lib/layout-surfaces.ts b/src/lib/layout-surfaces.tsindex 5d0537ab..06c3bba0 100644--- a/src/lib/layout-surfaces.ts+++ b/src/lib/layout-surfaces.ts@@ -98,6 +98,9 @@ const colourWords = (c: string) => (/^#[0-9a-f]{6}$/i.test(c) ? `colour ${c}` :const sentence = (s: string) => s.trim().replace(/[.\s]+$/, "");+/** The logo box's caption: the logo itself goes to the model as its last reference image (adDraft's `logo`). */+export const LOGO_CAPTION = "The brand's logo, exactly as in the last reference image, small and crisp";+/** An ad plan as a layout draft (see the file comment for the two modes). */export function adPlanDraft(plan: AdPlan, o: AdDraftOptions): LayoutDraft {const W = plan.w;@@ -119,7 +122,7 @@ export function adPlanDraft(plan: AdPlan, o: AdDraftOptions): LayoutDraft {if (plan.logo)items.push({label: "object",- caption: "The brand's logo, small and crisp",+ caption: LOGO_CAPTION,box: boxOf(plan.logo, W, H),});const text = (b: TextBox | undefined, what: string) => {@@ -188,11 +191,16 @@ export interface AdDraftInput {product: string;caption: string;meta?: string[];+ /**+ * The brand's logo goes to the model as its last reference image: plan its place. Without it there is no logo box,+ * so a model that draws from words alone doesn't make up a mark in the brand's name.+ */+ logo?: boolean;}/*** The layout for an ad or a Marketing Studio picture: planned as the browser would set it (planAd, with the brand's- * colours and fonts and the logo's place when there is one), then turned into a draft. The draft keeps the shape+ * colours and fonts, and the logo's place when the logo goes to the model), then turned into a draft. The draft keeps the shape* asked for, so the server compiles it at the size the model renders (src/lib/catalog/plan.ts planLayout).*/export function adDraft(i: AdDraftInput): LayoutDraft {@@ -203,7 +211,7 @@ export function adDraft(i: AdDraftInput): LayoutDraft {content: i.content,theme: themeFrom(i.brand),image: { w, h },- logo: i.brand?.logo ? { w: 3, h: 1 } : null,+ logo: i.logo && i.brand?.logo ? { w: 3, h: 1 } : null,measure: roughMeasure,});const draft = adPlanDraft(plan, {diff --git a/src/lib/licences.ts b/src/lib/licences.tsindex e67a17f0..57b49c74 100644--- a/src/lib/licences.ts+++ b/src/lib/licences.ts@@ -568,6 +568,12 @@ export const ATTRIBUTIONS: Attribution[] = [url: "https://huggingface.co/nvidia/NVIDIA-NemotronLabs-RE-USE",note: "Trained in part on WSJ (LDC) and an internal NVIDIA set (model card). The older nvidia/RE-USE repository is non-commercial (NSCLv1); Fuobe uses only the NemotronLabs repositories.",},+ {+ for: "The Layout Poster skill and Plan layout",+ text: "Adapted from MOSS-Image's prompt-enhancer skill and its layout reference (commit 2b46b1e), copyright OpenMOSS",+ licence: "Apache-2.0",+ url: "https://github.com/OpenMOSS/MOSS-Image",+ },];/** The parts of a LoRA's licence snapshot the class needs (src/lib/catalog/types.ts LoraLicence). */diff --git a/src/server/ads.ts b/src/server/ads.tsindex c168cc4a..1bc964b7 100644--- a/src/server/ads.ts+++ b/src/server/ads.ts@@ -183,8 +183,11 @@ export function visualRequest(): GenerationRequest {const modelId = drawn ? drawnWordsModel(engine, asked) : adVisualModel(engine, asked);const model = getModel(modelId);- // A model that draws from words alone (MOSS-Image, Ideogram 4.5) describes the product instead of copying the photo.+ // A model that draws from words alone (MOSS-Image) describes the product instead of copying the photo; one that+ // edits (Ideogram 4.5, FLUX.3) keeps the photo.const hero = drawn && model && !supportsOp(model, "edit") ? undefined : product?.images[0];+ // A drawn ad's logo is the brand's own, sent after the photo to a model that takes more than one; else no logo box.+ const logo = drawn && hero && model && (model.options.maxImages ?? 1) > 1 && brand.logo && !/\.svg(\?|$)/i.test(brand.logo) ? brand.logo : undefined;const aspect = model?.options.aspectRatios?.includes("4:5") ? "4:5" : model?.options.aspectRatios?.includes("3:4") ? "3:4" : undefined;const visual = c.visual.replace(/[.\s]+$/, "");const layout =@@ -195,6 +198,7 @@ export function visualRequest(content: drawn ? { headline: c.headline, body: c.body || undefined, cta: c.cta || undefined, brand: brand.name } : { headline: c.headline },brand,mode: drawn ? "words" : "clear",+ logo: !!logo,product: product ? `${product.name}: ${visual}` : visual,caption: "",meta: ["advertising", drawn ? "social media ad" : "photography"],@@ -208,14 +212,15 @@ export function visualRequest(op: hero ? "edit" : "t2i",prompt: [`${drawn ? "A finished social media ad" : "Advertising photograph"}: ${visual}`,- hero && "Keep the product exactly as in the reference photo: shape, label, logo, text and colours",+ hero && `Keep the product exactly as in the ${logo ? "first " : ""}reference photo: shape, label, logo, text and colours`,+ logo && "The last reference image is the brand's logo: place it as it is, in its box",brandLine(brand),!drawn && NO_TEXT,].filter(Boolean).join(". ").concat("."),- inputs: hero ? { images: [hero] } : undefined,+ inputs: hero ? { images: logo ? [hero, logo] : [hero] } : undefined,params: { aspectRatio: aspect, numOutputs: 1, ...(layout && { extra: { [LAYOUT_PARAM]: layout } }) },title: c.headline,batchTitle: `${brand.name} · ads`,diff --git a/src/server/assist/tools.ts b/src/server/assist/tools.tsindex c8ecf2c3..4ffe0dbf 100644--- a/src/server/assist/tools.ts+++ b/src/server/assist/tools.ts@@ -22,6 +22,8 @@ import { engineMode } from "../settings";import { readRef } from "../storage";import { katanaTool } from "../katana";import { createStoryboard, estimateStoryboard } from "../storyboard";+import { nearestAspect } from "../marketing";+import { LAYOUT_NODE_LIMITS } from "@/lib/catalog/canvas";import { CONTEXT_TOOLS } from "./context-tools";import { defineTool, type JobPlace, type ResultContent, type ToolContext, type ToolDef, type ToolOutcome } from "./define";// Fills STUDIO_ROUTES with the studio modules (Layers, Shorts, dub, Faceless, Ads, Captions).@@ -329,7 +331,7 @@ function toRequest(job: JobInput, engine?: "cloud" | "open"): GenerationRequest}/** A job as the request it names, before a retired model or operation is moved (toRequest). */-function asRequest(j: JobInput): GenerationRequest {+export function asRequest(j: JobInput): GenerationRequest {const inputs = {...(j.images?.length && { images: j.images }),...(j.end_image && { endImage: j.end_image }),@@ -340,7 +342,10 @@ function asRequest(j: JobInput): GenerationRequest {};const shots = j.shots && j.shots > 1 ? shotList(getModel(currentModelId(j.model_id)), j.shots) : undefined;// A layout draft (the layout-poster skill): read on its own canvas, compiled by the plan for the model it runs on.- const layout = j.layout ? parseLayout(j.layout)?.draft : undefined;+ // Up to 64 boxes (as a Canvas Layout node); its own shape becomes the run's only as the nearest one the model lists.+ const parsed = j.layout ? parseLayout(j.layout)?.draft : undefined;+ const layout = parsed && { ...parsed, items: parsed.items.slice(0, LAYOUT_NODE_LIMITS.boxes) };+ const layoutAspect = layout?.aspect && nearestAspect(layout.aspect, getModel(currentModelId(j.model_id))?.options.aspectRatios);const extra = { ...(j.system && { system: j.system }), ...(layout && { [LAYOUT_PARAM]: layout }) };return {feature: "assist",@@ -351,7 +356,7 @@ function asRequest(j: JobInput): GenerationRequest {negativePrompt: j.negative_prompt,inputs: Object.keys(inputs).length ? inputs : undefined,params: {- aspectRatio: j.aspect_ratio ?? layout?.aspect,+ aspectRatio: j.aspect_ratio ?? layoutAspect,resolution: j.resolution,duration: shots ? undefined : j.duration,numOutputs: j.outputs ? Math.max(1, Math.min(4, j.outputs)) : undefined,diff --git a/src/server/marketing.ts b/src/server/marketing.tsindex c2f998ae..ad06c108 100644--- a/src/server/marketing.ts+++ b/src/server/marketing.ts@@ -342,6 +342,10 @@ export function planMarketing(input: MarketingInput, ctx: PlanContext): RunPlanop = "edit";}if (op === "t2i") images = [];+ // Words drawn by the model: the brand's own logo goes after the photos to a model with room for it, so the layout's+ // logo box is the real logo (a model that draws from words alone gets no logo box: it would make one up).+ const drawnLogo = drawn && op === "edit" && images.length > 0 && images.length < max ? rasterLogo(brand) : undefined;+ if (drawnLogo) images = [...images, drawnLogo];const headline = input.headline?.trim() || (tpl?.headline ? fill(tpl.headline, product, brand) : "");const cta = input.cta?.trim() || (tpl?.cta ? fill(tpl.cta, product, brand) : "");const person = input.avatar ? "the person from the reference photo (same face, hair, skin tone and build)" : "a natural-looking model who suits the product";@@ -359,6 +363,7 @@ export function planMarketing(input: MarketingInput, ctx: PlanContext): RunPlanscene,productLine(product),hasProduct && op === "edit" && KEEP_PRODUCT,+ drawnLogo && "The last reference image is the brand's logo: place it as it is, in its box",input.reference && "Use the last reference photo for the setting and light",prompt,// Drawn words come from the layout's text boxes, in their places.@@ -381,6 +386,7 @@ export function planMarketing(input: MarketingInput, ctx: PlanContext): RunPlancontent: { headline, cta: cta || undefined },brand,mode: "words",+ logo: !!drawnLogo,product: product ? `${product.name}${product.description ? `, ${product.description.replace(/\s+/g, " ").trim().slice(0, 160)}` : ""}` : scene || prompt || "The subject of the picture",caption: "",meta: [f.id === "poster" ? "poster" : "advertising", "graphic design"],diff --git a/tests/layouts-everywhere.test.ts b/tests/layouts-everywhere.test.tsindex 3527dd40..41d4445d 100644--- a/tests/layouts-everywhere.test.ts+++ b/tests/layouts-everywhere.test.ts@@ -14,7 +14,7 @@ const { getModel, getPreset } = await import("@/lib/catalog");const { planGeneration } = await import("@/lib/catalog/plan");const { describeNode, cleanGraph } = await import("@/lib/catalog/canvas");const { compileMoss, validateLayout, readsBoxes } = await import("@/lib/layout-prompt");-const { adDraft, adPlanDraft, fillLayout, layoutPlaceholders, productRect, roughMeasure } = await import("@/lib/layout-surfaces");+const { adDraft, adPlanDraft, fillLayout, layoutPlaceholders, LOGO_CAPTION, productRect, roughMeasure } = await import("@/lib/layout-surfaces");const { planAd, themeFrom } = await import("@/components/ads/layout");const { DRAWN_WORDS_MODELS, drawnWordsModel, formatModels, FORMATS, wordsOnTop, MARKETING_IMAGE_MODEL } = await import("@/lib/catalog/marketing");const { planByRules, readPlanned } = await import("@/lib/layout-plan");@@ -24,6 +24,7 @@ const ads = await import("@/server/ads");const { planLayoutFromWords } = await import("@/server/layout-plan");const skills = await import("@/server/skills");const canvasServer = await import("@/server/canvas");+const tools = await import("@/server/assist/tools");import type { CanvasEdge, CanvasGraph, CanvasNode } from "@/lib/catalog/canvas";import type { BrandKit, Product } from "@/lib/catalog/marketing";@@ -81,7 +82,7 @@ describe("an ad plan as a layout (AdPlan → draft)", () => {const d = adPlanDraft(plan, { mode: "words", product: "Autumn Soy Candle in amber glass", caption: "A finished social ad" });const texts = d.items.filter((i) => i.label === "text").map((i) => i.text?.replace(/\n/g, " "));expect(texts).toEqual(["Autumn Glow", "Hand-poured soy, cedar and clove.", "Shop now"]);- expect(d.items.find((i) => i.caption === "The brand's logo, small and crisp")?.label).toBe("object");+ expect(d.items.find((i) => i.caption === LOGO_CAPTION)?.label).toBe("object");const prod = d.items.find((i) => i.caption.startsWith("Autumn Soy Candle"))!;expect(prod.label).toBe("object");// The product stays out of the words' space, and every box is inside the picture.@@ -272,7 +273,14 @@ describe("Marketing Studio: Words drawn by the model", () => {expect(moss.steps[0].request).toMatchObject({ modelId: "moss-image", op: "t2i" });expect((moss.steps[0].request.params?.extra?.layout as LayoutDraft).items.some((i) => i.text === "Autumn Glow")).toBe(true);const flux = mk.planMarketing({ engine: "cloud", format: "ads", templateId: "ad-hero-headline", modelId: "flux-3", drawnWords: true }, ctx);- expect(flux.steps[0].request).toMatchObject({ modelId: "flux-3", op: "edit", inputs: { images: [product.images[0]] } });+ expect(flux.steps[0].request).toMatchObject({ modelId: "flux-3", op: "edit", inputs: { images: [product.images[0], brand.logo] } });+ expect((flux.steps[0].request.params?.extra?.layout as LayoutDraft).items.filter((i) => i.caption === LOGO_CAPTION)).toHaveLength(1);+ // MOSS-Image can't take the logo: no logo box for it to make one up in.+ expect((moss.steps[0].request.params?.extra?.layout as LayoutDraft).items.some((i) => /logo/i.test(i.caption))).toBe(false);+ // Ideogram 4.5 edits: it keeps the product photo and takes the logo too.+ const ideo = mk.planMarketing({ engine: "cloud", format: "ads", templateId: "ad-hero-headline", modelId: "ideogram-4-5", drawnWords: true }, ctx);+ expect(ideo.steps[0].request).toMatchObject({ modelId: "ideogram-4-5", op: "edit", inputs: { images: [product.images[0], brand.logo] } });+ expect(ideo.notes.join(" ")).not.toMatch(/draws your product from its name/);// The estimate prices the drawing model.const est = mk.estimateMarketing({ engine: "cloud", format: "ads", templateId: "ad-hero-headline", drawnWords: true, productImages: product.images });expect(est.steps?.[0]?.modelId ?? JSON.stringify(est)).toMatch(/moss-image/);@@ -288,13 +296,33 @@ describe("Ads Studio: drawn ads and the keep-clear layout", () => {expect(open).toMatchObject({ modelId: "oss-moss-image", op: "t2i", params: { aspectRatio: "4:5" } });expect(open.prompt).not.toMatch(/No text, letters/);const layout = open.params?.extra?.layout as LayoutDraft;- expect(layout.items.filter((i) => i.label === "text").map((i) => i.text?.replace(/\n/g, " "))).toEqual(["Autumn Glow", "Hand-poured soy.", "Shop now"]);- expect(layout.items.some((i) => i.caption === "The brand's logo, small and crisp")).toBe(true);+ expect(layout.items.filter((i) => i.label === "text").map((i) => i.text?.replace(/\n/g, " "))).toEqual([brand.name.toUpperCase(), "Autumn Glow", "Hand-poured soy.", "Shop now"]);+ // MOSS-Image draws from words alone: it can't take the logo, so the brand's name is drawn in its place, not a made-up logo.+ expect(layout.items.some((i) => /logo/i.test(i.caption))).toBe(false);const cloud = ads.visualRequest(concept, product, brand, "cloud", "ideogram-4-5", true);expect(cloud.modelId).toBe("ideogram-4-5");expect(planGeneration(cloud, getModel, getPreset).layout?.format).toBe("ideogram");});+ it("a model that takes references keeps the product photo and gets the brand's own logo for its logo box", () => {+ for (const id of ["ideogram-4-5", "flux-3"]) {+ const r = ads.visualRequest(concept, product, brand, "cloud", id, true);+ expect(r, id).toMatchObject({ modelId: id, op: "edit", inputs: { images: [product.images[0], brand.logo] } });+ expect((r.params?.extra?.layout as LayoutDraft).items.filter((i) => i.caption === LOGO_CAPTION), id).toHaveLength(1);+ expect(r.prompt, id).toMatch(/last reference image is the brand's logo/);+ }+ // No logo in the kit (or an SVG one): no logo box, the photo alone.+ for (const logo of [undefined, "/api/files/logo.svg"]) {+ const r = ads.visualRequest(concept, product, { ...brand, logo } as BrandKit, "cloud", "flux-3", true);+ expect(r.inputs?.images).toEqual([product.images[0]]);+ expect((r.params?.extra?.layout as LayoutDraft).items.some((i) => /logo/i.test(i.caption))).toBe(false);+ }+ // Without a product photo there is nothing to edit: drawn from words, no logo.+ const bare = ads.visualRequest(concept, null, brand, "cloud", "ideogram-4-5", true);+ expect(bare).toMatchObject({ op: "t2i", inputs: undefined });+ expect((bare.params?.extra?.layout as LayoutDraft).items.some((i) => /logo/i.test(i.caption))).toBe(false);+ });+it("without it: the visual alone, and a keep-clear layout only for a model that reads boxes", () => {const plain = ads.visualRequest(concept, product, brand, "cloud");expect(plain.params?.extra).toBeUndefined();@@ -377,3 +405,30 @@ describe("Plan layout and the Layout Poster skill", () => {expect(readPlanned(example, 768, 1024)?.items).toHaveLength(4);});});++// ---------------------------------------------------------------------------++describe("Assist: a generate job's layout", () => {+ const pixel = (n: number) => ({+ width: 896,+ height: 1152,+ bbox_coord_space: "abs",+ bbox_format: "xyxy",+ summary: { caption: "A sale poster", meta: ["poster"], canvas: "single" },+ items: Array.from({ length: n }, (_, i) => ({ label: "text", caption: "Bold words", text: `Line ${i + 1}`, bbox: [16, 16 + (i % 60) * 16, 400, 30 + (i % 60) * 16] })),+ });++ it("runs in the nearest shape the model lists, and keeps at most 64 boxes", () => {+ for (const id of ["flux-3", "ideogram-4-5"]) {+ const r = tools.asRequest({ model_id: id, prompt: "A poster", layout: pixel(3) } as Parameters<typeof tools.asRequest>[0]);+ const listed = getModel(id)!.options.aspectRatios!;+ expect(listed, id).not.toContain("7:9");+ expect(listed, id).toContain(r.params?.aspectRatio);+ expect((r.params?.extra?.layout as LayoutDraft).aspect).toBe("7:9");+ }+ // An aspect the job names wins.+ expect(tools.asRequest({ model_id: "flux-3", prompt: "x", layout: pixel(1), aspect_ratio: "1:1" } as Parameters<typeof tools.asRequest>[0]).params?.aspectRatio).toBe("1:1");+ const many = tools.asRequest({ model_id: "flux-3", prompt: "x", layout: pixel(80) } as Parameters<typeof tools.asRequest>[0]);+ expect((many.params?.extra?.layout as LayoutDraft).items).toHaveLength(64);+ });+});