Content News Thai
Generate news-style post images with Thai text overlay + captions for social media.
Setup (first time only)
Run the setup script to install dependencies (canvas, Thai fonts):
CODEBLOCK0
On Docker/VPS this installs: libcairo2, libpango, Thai fonts (Kanit, Prompt, Sarabun).
On macOS: uses Homebrew for cairo/pango.
Generate News Image
CODEBLOCK1
Parameters
| Param | Required | Description |
|---|
| headline | ✅ | Main headline (Thai/English, auto-wraps) |
| sub |
| Sub-headline text |
| badge | | Badge label (default: "AI NEWS") |
| badgeColor | | Badge color (default: "#CC0000") |
| bgImage | | Background image path or URL |
| bgColor | | Fallback bg gradient color (default: "#0a0a1a") |
| source | | Source attribution at bottom |
| output | ✅ | Output file path (.jpg) |
| brandName | | Watermark text (bottom-right) |
| accentColor | | Bottom bar color (default: "#CC0000") |
Example
CODEBLOCK2
Output: JSON INLINECODE0
Background Image
Two approaches:
- 1. With bgImage — provide a path/URL to a photo. The script covers it with dark gradient for text readability.
- Without bgImage — generates a dark gradient background with subtle grid pattern. Good for text-focused posts.
For best results, generate a background image first (use the AI model's image generation), save it, then pass the path as bgImage.
Workflow: Full Content Set
When asked to create a complete content set:
- 1. Write headline + sub — short, punchy, Thai-friendly
- Generate background — use AI image gen or use bgColor for clean look
- Run gen-news.mjs — creates 1080x1350 image with Thai text overlay
- Write caption — storytelling style, short sentences, end with engaging question
- Return — image path + caption to user
Caption Style Guide
- - Open with a scroll-stopping hook (short, impactful)
- Tell the story with short sentences, reveal layer by layer
- Include the brand's perspective/opinion
- End with: impact summary → specific question → soft share cue (if appropriate)
- Add 3-5 relevant hashtags
- Do NOT end with generic "คิดเห็นยังไงคอมเมนต์มา"
Troubleshooting
- - "canvas" error → rerun setup.sh
- Fonts look wrong → check assets/fonts/ has .ttf files, rerun setup.sh
- bgImage not found → use absolute path or URL
Content News Thai
生成带有泰语文字叠加和说明文字的社交媒体新闻风格图片。
设置(仅首次使用)
运行设置脚本以安装依赖项(canvas、泰语字体):
bash
bash /scripts/setup.sh
在 Docker/VPS 上,此操作会安装:libcairo2、libpango、泰语字体(Kanit、Prompt、Sarabun)。
在 macOS 上:使用 Homebrew 安装 cairo/pango。
生成新闻图片
bash
cd /scripts && node gen-news.mjs
参数
| 参数 | 必填 | 描述 |
|---|
| headline | ✅ | 主标题(泰语/英语,自动换行) |
| sub |
| 副标题文字 |
| badge | | 标签文字(默认:AI NEWS) |
| badgeColor | | 标签颜色(默认:#CC0000) |
| bgImage | | 背景图片路径或URL |
| bgColor | | 备用背景渐变颜色(默认:#0a0a1a) |
| source | | 底部来源标注 |
| output | ✅ | 输出文件路径(.jpg) |
| brandName | | 水印文字(右下角) |
| accentColor | | 底部栏颜色(默认:#CC0000) |
示例
bash
cd DIR>/scripts && node gen-news.mjs {headline:AI กำลังเปลี่ยนวงการค้าปลีก,sub:ยอดขายพุ่ง 40% ใน 6 เดือน,badge:BREAKING NEWS,source:Reuters • มี.ค. 2026,brandName:MY BRAND,output:/tmp/newspost.jpg}
输出:JSON {status:done,output:/tmp/news_post.jpg,size:1080x1350,type:image}
背景图片
两种方法:
- 1. 使用 bgImage — 提供图片路径/URL。脚本会覆盖深色渐变以提高文字可读性。
- 不使用 bgImage — 生成带有细微网格图案的深色渐变背景。适合以文字为主的帖子。
为获得最佳效果,请先生成背景图片(使用AI模型的图片生成功能),保存后,将路径作为 bgImage 传入。
工作流程:完整内容集
当要求创建完整内容集时:
- 1. 撰写标题 + 副标题 — 简短、有力、适合泰语
- 生成背景 — 使用AI图片生成或使用 bgColor 保持简洁外观
- 运行 gen-news.mjs — 创建带有泰语文字叠加的1080x1350图片
- 撰写说明文字 — 故事叙述风格,短句,以引人思考的问题结尾
- 返回 — 图片路径 + 说明文字给用户
说明文字风格指南
- - 以吸引注意力的开场白开头(简短、有冲击力)
- 用短句讲述故事,层层递进
- 包含品牌的视角/观点
- 以以下内容结尾:影响总结 → 具体问题 → 软性分享提示(如适用)
- 添加3-5个相关话题标签
- 不要以通用的คิดเห็นยังไงคอมเมนต์มา结尾
故障排除
- - canvas 错误 → 重新运行 setup.sh
- 字体显示异常 → 检查 assets/fonts/ 是否有 .ttf 文件,重新运行 setup.sh
- bgImage 未找到 → 使用绝对路径或URL