AI blog images with SVG: an editable agent workflow
Generate AI blog images with a reusable background and editable SVG foreground. A runnable Node.js example with profiles, text edits and WebP export.

TL;DR: An agent doesn’t need an image-generation call for every part of a blog image. Generate or choose the background, keep the exact text and foreground elements in SVG, then combine them for the final export. Save the layers and a small visual profile so the next change doesn’t mean starting over. Below is a runnable example using one background and two different layouts.
At Tenwrite, we are building an agent that researches topics and writes blog drafts. I wrote about one of its context problems in the Trimwise benchmark post. Naturally, once an agent starts preparing posts, the question of images comes along too.
The tempting approach is to describe the entire image to an image model. Give it the topic, title, colour palette, layout, icons, arrows and maybe a small diagram. Wait for the result, check it, adjust the prompt and repeat.
Well, say the illustration comes out nicely. Then you change the title. Or the arrow needs to point somewhere else. Or the picture is fine but the text needs to move a little. Why should any of those changes require generating the whole picture again?
That is the part I wanted to separate. Image generation can do the atmospheric work. A coding agent can write SVG, and ordinary code can place text and shapes at coordinates we control. Might as well use those capabilities too. 😄
Give each part a smaller job
Think of the final image as a composition with separate source files:
| Part | What I keep in it |
|---|---|
| Base | Texture, atmosphere or a scene. Generated artwork, my own art or an asset I have permission to use. |
| SVG | Exact words, icons, arrows, boxes and relationships, placed with an explicit layout. |
| Profile | The chosen layout, accent and short copy, saved as editable configuration. |
| Export | The combined image, rendered to WebP or another format the site supports. |
For a technical walkthrough, I might want a clear process diagram. For a personal essay, a strong illustration and a quiet title area could make more sense. A football post could use a pitch diagram; a music post could lean on a record-sleeve composition. The article should influence the choice. Everything doesn’t need to become three boxes connected by arrows.
Sometimes the background can just be a solid colour. Sometimes the whole visual can be SVG. And sometimes the illustration really does need the image model. I don’t want to add a generation step just because the agent has access to one.
The useful distinction is what needs to stay editable. Even if the first generated image gets every word right, a title embedded in those pixels is still inconvenient to change later.
Where Tenwrite already uses this idea
Tenwrite’s blogger agent already separates visual planning from drawing. The writer supplies a bounded visual direction: a concept, relevant symbols, mood, accent and optional short label. Local renderers turn that direction into SVG using predefined cover compositions and diagram layouts. The publishing side rasterizes the result.
So the model helps decide what the image should communicate, while the renderer owns the geometry and presentation. We also keep a composition stable across retries rather than randomly redesigning it each time.
That existing path doesn’t require an image-generation model. The generated-background workflow in this guide is a separate example extending the idea, rather than a feature I am claiming is already wired into Tenwrite. The source download below is original example code, not a copy of the service.
What I like about this direction is that a more expressive background can fit around a layout we already know how to render and edit. It doesn’t require giving up control over the foreground.
Start with a profile
A profile should tell the agent what sort of composition it can use. It can carry a layout choice, a palette and short copy, while the actual template defines positions, typography and shapes.
Here is the editorial entry from the example’s profiles.json:
{
"template": "editorial",
"accent": "#e6ec70",
"kicker": "MAKER'S NOTES / 01",
"lines": ["MAKE THE MOOD.", "DRAW THE DETAILS."],
"alt": "An editorial cover with two headline lines beside three offset printing plates."
}
The other profile, workflow, puts the headline above a process illustration. It uses the same background, but a different SVG template. A profile is more useful when it changes the composition to suit the content, rather than just replacing blue with green.
For an agent, I would make the selection task explicit: read the article, decide what a visual would help explain, choose a suitable profile, then fill its supported fields. If none fits, leave that for review. Picking a vaguely related icon from a keyword isn’t much of an editorial decision.
For my own images, I can also ask the coding agent to edit the SVG template directly. Move a group, change a path, adjust the spacing, render and inspect. For a service preparing other people’s posts, I prefer reviewed templates and validated fields. An automatically selected profile should not quietly become permission to replace the renderer.
With the example files available, I can give an agent a request like this:
Read this article, profiles.json and both SVG templates.
Choose the profile that best communicates the article's main idea.
Reuse background.webp. Edit the chosen profile's short copy and
description, respecting its limits. If neither layout fits, explain
what needs changing before editing the template.
Render the result and inspect it at full size and thumbnail size.
Return the export path and keep the editable source files.
That gives it a decision to make and something to check afterwards. I don’t have to specify every coordinate in a chat message.
Generate the background once
For this example, I used the built-in image tool to make a dark printmaking-workbench background. The useful part of the brief was:
Charcoal-black printer's workbench with restrained worn-paper
and halftone texture. Small ink brayer at the upper-right edge,
torn bone-white paper at the lower-left edge. Keep the central
field calm and dark for a separate foreground composition.
No text, logos, symbols or diagrams.
The download includes the full prompt and the resulting background.webp, so following along doesn’t require an image account or API key. Generating your own background is optional. The one used here looks like this:
Notice that there is no title or diagram for the model to place. I still had to inspect the result. A prompt asking for empty space doesn’t guarantee that the actual image leaves enough of it. Some of the edge texture is busy, so the SVG uses dark backing behind labels that would otherwise sit on it.
This is also where I’d keep the source asset’s provenance: which generated file I approved, the generation brief, or the licence and attribution for an external asset. Reusing a background should not mean forgetting where it came from.
Add the SVG foreground and export
Download the complete runnable example, extract it and open a terminal inside ai-image-layers:
npm ci
npm test
npm run render -- editorial
npm run render -- workflow
I ran it on Linux with Node.js 24.18.0 and Sharp 0.35.5. The example declares Node.js 22.12 or newer and pins its dependency in the included lockfile. Installing dependencies needs network access on a fresh machine; rendering the supplied assets doesn’t.
You get four files under output/: an SVG foreground and a WebP export for each profile. Keep the SVGs, templates, profiles and background. The WebP is the flattened delivery file; it cannot give you those layers back.
The compositing step is small:
const image = await sharp(background)
.resize(1200, 800, { fit: 'cover' })
.composite([{ input: Buffer.from(svg), left: 0, top: 0 }])
.webp({ quality: 88 })
.toBuffer();
Here, background is the local image buffer and svg is the filled foreground template. Sharp resizes the base before compositing. The overlay uses the same 1200 × 800 canvas, with its origin at the top left. Its compositing documentation explains the sizing and placement rules.
The editorial result:
The workflow result:
One generated background, two foreground compositions. The render commands make no image-model calls. Both runs print the same backgroundSha256, so you can check that they really used the same asset. They also print separate hashes for the SVG and final image.
This isn’t a speed or cost benchmark against full-image generation. The concrete thing demonstrated here is that changing the foreground doesn’t require another background-generation call.
Now change something without starting over
Open profiles.json and change the editorial headline to:
"lines": ["CHANGE THE WORDS.", "KEEP THE ART."]
Save it, then run npm run render -- editorial again. The title changes, while the background stays the same. You can change the accent too. If you want to move the printing plates, open templates/editorial.svg and edit the shapes themselves.
The rendered foreground uses ordinary SVG text:
<text x="78" y="326" fill="#e9e6db"
font-family="DejaVu Sans Mono, monospace"
font-size="52" font-weight="bold">MAKE THE MOOD.</text>
The renderer replaces that slot with escaped text. It doesn’t treat a headline as markup. Template names come from an allowlist, and accent values must be six-digit hex colours.
There are limits. This small demo accepts two printable ASCII headline lines of up to 20 characters each. Longer copy fails with an error; it doesn’t keep reducing the font until the title becomes unreadable. SVG text doesn’t wrap by default, so a general-purpose version needs deliberate text measurement, line breaking and overflow handling. Fonts matter too: these renders use DejaVu Sans Mono, and another machine’s fallback can look different.
The three included tests exercise escaping, invalid profile values, both actual exports, dimensions and repeatability on the same machine. They don’t decide whether the composition is good. I still have to look at the full image, a small thumbnail and the crop my site actually uses.
Keep the editable source, publish the useful image
For a blog, I would keep the layered sources in the project and publish an optimized raster export. The article title and explanation still belong in the page’s HTML. Putting them inside an image doesn’t replace the written content.
Use a descriptive filename, explain the image with useful alt text and place it near the section it supports. Check the file size and reserve its dimensions in the page. Google’s image SEO guidance covers these basics; the fact that an image contains generated artwork or SVG layers doesn’t give it a special ranking advantage.
For a hosted agent, there is also a boundary to keep. This example renders trusted local templates and an approved local background. It isn’t a sandbox for arbitrary SVG uploads. Remote assets, unknown SVG markup, enormous images and uncontrolled fonts need separate handling before they reach a renderer. Keeping model output to validated content and profile choices makes that job smaller.
I like using agents for this because the work becomes inspectable. I can see the chosen profile, read the SVG and change a specific element. It is the same ownership concern I wrote about in A skill issue: I want to understand and keep control of what the agent produces.
If the background works, keep it. If the title needs changing, edit the title. If the layout doesn’t suit the article, pick another one or fix the SVG. There is no need to ask the image model to repaint the workbench because I moved an arrow. 😄