haomeme_generate
Generates a 1280×720 HaoMeme-style meme PNG in your project folder from a JSON spec, rendering through a headless browser so fonts, portraits, paint strokes, and layout match the web UI.
Instructions
Generate ONE HaoMeme-style meme PNG (1280x720) into this project folder. Renders by driving the original HaoMeme web app in a local headless browser, so fonts, built-in portraits, paint stroke and layout match the web UI exactly. spec = one object of optional fields (full reference: FIELD_HELP below, or call haomeme_catalog). RULES THAT MATTER: (1) line breaks are written as the two characters backslash-n inside the JSON argument, e.g. "第一行\n第二行" — a literal newline can be dropped and your two captions will end up on one line; (2) lineColors is ONE colour per line (white|yellow|red), default white then yellow; (3) template teaches/crash put the portrait on the LEFT, nope puts it on the RIGHT. Example: {"template":"teach","portrait":"A","backdrop":"red","text":"老黃說退就退\n#OpenToWork","lineColors":["white","yellow"]}. outputDir must stay inside the project folder (default ./output; override with HAOMEME_OUTPUT_ROOT). Returns {ok, path, bytes, width, height, template, text}; a failure is returned as {ok:false, error}. For 2+ images prefer haomeme_batch_generate — one browser page is reused and it is much faster.
FIELD REFERENCE (all optional, omitted = template default): HaoMeme spec fields — EVERY field is optional; an omitted field keeps that template's own default: text string, max 300 chars. The headline. To break a line write the two characters backslash-n ("\n") INSIDE the JSON argument, e.g. "第一行\n第二行". Do NOT rely on a literal line-break character in the JSON string: some clients drop it and the two captions collapse onto one line (and the filename loses the break too). Omit text to use the template preset listed below. template teach | crash | nope | sue (default: teach) lineColors array, max 8, ONE colour per line: white | yellow | red. Line 1 defaults to white, line 2 to yellow, any extra line to white. The colour is per LINE, not per character. portrait built-in portrait key (single letter, from haomeme_catalog's live list). Overrides portraitIndex. portraitIndex zero-based index into that portrait list (alternative to portrait). backdrop red | classroom | oldClassroom | room | grey | dark | smoke red = flat red with the paint stroke; the others are photo sets. side left | right — which side the portrait sits on. textSize 30..220 (100 = default, bigger = larger type) rotation -180..180 degrees of text rotation brushSize 30..250 (100 = default) — red paint-stroke thickness portraitSize 30..260 (100 = default) backgroundSize 10..300 (100 = default) backgroundBlur 0..30 px — blur on photo backdrops redBrush boolean — show the red paint stroke under the text brushInFront boolean — paint stroke in front of the portrait (still below the text) italic boolean — lean the text to the right flip boolean — mirror the portrait
LAYOUT (verified by actually rendering): teach and crash = portrait on the LEFT with the big headline on the right; nope = portrait on the RIGHT with the text on the left; sue = the lawyer-letter style. Use nope when you want the portrait and the text on opposite sides from teach/crash.
Preset text used when "text" is omitted: teach 輪到你\n教育我了? crash AI教育\n翻車了? nope 想玩GTA6?\n免談 sue 你準備收\n律師傳票
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"spec": "<spec>"
},
"name": "haomeme_generate"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spec | Yes | ||
| outputDir | No | Folder inside this project; defaults to ./output. Paths outside the project root are rejected (set HAOMEME_OUTPUT_ROOT to change the root). |