Logo composite

From BuilderIO/agent-native · View interactive version

Logo composite is an AI agent skill from the GitHub repository BuilderIO/agent-native. How the generate-then-composite pipeline puts a pixel-perfect canonical logo onto a generated image without letting the LLM regenerate the logo.

How to use this skill

Skill file

Logo composite

LLMs — including Gemini Pro — degrade complex logos. They smear gradients, drop text, and rearrange elements. The Assets app sidesteps this entirely with a generate-then-composite pipeline that every serious brand-imagery system uses today.

How it works

  1. The library has a canonicalLogoUrl (set via set-canonical-logo --libraryId --assetId). The asset's role is logo_reference.
  2. Logo compositing is an associated-template option. A Template carries includeLogo (stored in its settings and surfaced as a first-class field). Global templates cannot enable it because a canonical logo belongs to a brand kit. When a generation resolves to an associated template with includeLogo: true, generate-image composites the logo. A generate call's own includeLogo arg, when passed, overrides the template for that run; when omitted, the template's value wins.
  3. Template skeletons generalize logo compositing. An associated template can carry settings.skeletonSpec: background first, generated subject second, foreground layers last. If the skeleton already has a foreground layer with source: "canonicalLogo", includeLogo is treated as a no-op for that run so the logo is not stamped twice. If the skeleton does not include the logo and includeLogo is true, the existing canonical-logo layer is appended at the default upper-right position during compositing.
  4. When logo compositing is on, the prompt envelope adds:

> Leave a clean uncluttered area in the upper-right for the real brand logo; do not draw or approximate the logo yourself.

  1. Gemini returns an image with empty space in that corner.
  2. compositeLogo() from server/lib/image-processing.ts (Sharp) loads the canonical logo PNG / SVG, resizes it to ~16% of the image width with reasonable inset, and composites it onto the generated image. Skeleton runs use applyPresetSkeleton() at the same seam.
  3. Output: the image with the actual logo, pixel-perfect, vector-quality if the source is SVG.

Set includeLogo via create-template / update-template after associating

the template with a brand kit. The *-generation-preset actions are deprecated

aliases retained for existing threads.

generate-image / generate-image-batch stamp the library's pixel-perfect

canonical logo onto the result when the resolved template has it on, and it is a

no-op if the library has no canonical logo. The model never draws the logo

itself.

Template skeletons

Template skeletons live in settings.skeletonSpec on associated templates and

are edited from /templates/:templateId. They composite a

generated subject onto an uploaded brand background image and optional

foreground layers.

settings.skeletonSpec is the prototype storage shape:

{
  background: { type: "asset"; assetId: string };
  mask?: { type: "asset"; assetId: string };
  contentMode: "fill" | "cutout";
  contentRegion?: { x: number; y: number; w: number; h: number };
  dropShadow?: boolean;
  foreground?: Array<{
    source: "canonicalLogo" | { assetId: string };
    x: number;
    y: number;
    w: number;
  }>;
}

When to use it

When NOT to use it

Compositing onto a flat corner is fine; compositing onto a curved or perspective surface needs mask-based inpainting. Use a gpt-image-2 skeleton plate with transparent editable regions when that exact layout is required.

Setting a canonical logo

upload reference image (role: logo_reference, category: logo) →
set-canonical-logo --libraryId=<id> --assetId=<asset-id>

set-canonical-logo flips the asset's role to logo_reference AND its status to reference. This means the reference selector won't pick up generated logo candidates as canonical — only intentionally pinned uploads.

Sharp composite parameters (current defaults)

In image-processing.ts:compositeLogo():

If you change these, also update the corresponding language in the prompt envelope ("upper-right") so the LLM's clean area aligns with where Sharp will composite.

Why not in-image text?

The same logic applies to body and headline text. Image models still smear small letters and rearrange long strings. The Assets app's prompt envelope explicitly says:

Do not render headlines, body text, UI labels, or prompt wording inside the image unless the user explicitly asks for exact visible text.

Overlay text in HTML/CSS in the calling app (slides, design, mail) — it's more reliable, more accessible, and the user can edit it without re-running the generation.

Failure modes & detection

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.