name: text-to-image description: Render text into an image and return a temporary local image file path, with optional data URI. Use when Clawhub or Codex needs to convert plain text, styled text, colored text, multilingual text, slogans, posters, captions, or text snippets into an image with controllable width, height, format, font size, full-text color, or partial text colors. Support svg, png, jpg, and jpeg output, return a real temp file path under the skill tmp folder, and work across Windows and macOS with built-in font fallback. Also use for 文本轉圖片、文字轉圖片、生成文字海報、彩色文字圖片、指定尺寸文字圖、區域性文字顏色、高亮部分文字、輸出臨時圖片地址、返回本地圖片路徑、返回 image 檔案路徑、指定 svg/png/jpg 格式、Mac 相容、Windows 相容、return temp file path, local image path, or data URI output.
Use scripts/render_text_image.py to generate an image and return a local file path. The script can also include a data: image URL when needed.
Prefer the script over hand-writing image payloads. The script already handles:
svg, png, jpg, jpegtmp/font_size is omittedPass a JSON spec through --spec-json or --spec-file.
Supported fields:
{
"text": "Hello\nWorld",
"highlight_ranges": [
{ "start": 0, "end": 5, "color": "#111111" },
{ "start": 6, "end": 11, "color": "#ff4d4f" }
],
"highlight_texts": [
{ "match": "World", "color": "#1677ff", "occurrence": "all", "case_sensitive": true }
],
"segments": [
{ "text": "Hello ", "color": "#111111" },
{ "text": "World", "color": "#ff4d4f" }
],
"width": 1200,
"height": 630,
"format": "png",
"font_size": 72,
"min_font_size": 12,
"default_color": "#111111",
"background": "#ffffff",
"padding": 48,
"line_height": 1.2,
"align": "center",
"valign": "middle",
"font_family": "Microsoft YaHei, PingFang SC, Arial, sans-serif"
}
Rules:
text or segments. If both are present, segments wins.text + highlight_texts for simple "make this word red" requests.highlight_ranges when the caller knows character positions.segments only when the caller already has exact pieces split out.\n when a hard line break is required.font_size to make the script auto-fit the whole text inside the image.font_size is provided, the script keeps that size and still wraps lines as needed.svg is the default format.png over jpg for text-heavy images.format is jpg or jpeg, transparent background is converted to white.Priority:
segmentstext + highlight_ranges / highlight_textstext onlyFriendly highlight format:
{
"text": "ClawHub makes text visible",
"highlight_texts": [
{ "match": "ClawHub", "color": "#1677ff" },
{ "match": "visible", "color": "#fa541c" }
]
}
Range format:
{
"text": "Hello World",
"highlight_ranges": [
{ "start": 6, "end": 11, "color": "#ff4d4f" }
]
}
file_path to the caller when the next step is file upload.image_url only when the caller explicitly needs a data URI.Example:
@'
{
"segments": [
{ "text": "Claw", "color": "#111111" },
{ "text": "Hub", "color": "#1677ff" }
],
"width": 1024,
"height": 512,
"format": "png",
"background": "#ffffff",
"padding": 40
}
'@ | Set-Content spec.json
python scripts/render_text_image.py --spec-file spec.json --no-data-url
The script prints JSON:
{
"file_path": "E:\\clawhub\\text-to-image\\tmp\\rendered-0000.png",
"relative_file_path": "tmp/rendered-0000.png",
"file_name": "rendered-0000.png",
"file_size": 21550,
"mime_type": "image/png",
"format": "png",
"width": 1024,
"height": 512,
"font_size": 96.0,
"line_count": 1,
"resolved_segments": [
{ "text": "Claw", "color": "#111111" },
{ "text": "Hub", "color": "#1677ff" }
]
}
svg is lightweight, crisp, and ideal for text rendering.png is the best general-purpose bitmap choice for text images.7w4.net提供免費和付費技能下載。
jpg is supported for compatibility, but it is usually not the best default for text.tmp/ folder by default.--output path.ext to control where the file is written.--no-data-url when the caller only needs upload-ready file metadata.PingFang and STHeiti before falling back.Microsoft YaHei, SimHei, and Arial.testcases/, including 13-wrap-example.json for fixed-size wrapping.這是一款質量紮實的文生圖工具,操作流程順暢,文件圖文並茂。它的最大優點是「傻瓜式」初始化引導和三保險配置方式(命令、環境變數、檔案),普通人也能快速上手。生成、查詢、上傳三個核心功能都有覆蓋,輪詢等待時還有進度提示,體驗友好。不足之處是隻能使用固定模型,缺少模型切換選項,靈活性受限。如果平臺後續支援更多圖片模型,可進一步提升競爭力。