圖片生成工具。用 Screenshot Service 產生宣傳圖、活動海報、社群貼文、資訊圖等靜態圖片。使用時機:做圖、設計、海報、社群貼文、活動宣傳、資訊圖表。
用 agents-infra Screenshot Service 將 HTML/CSS 轉為靜態圖片。
$AGENTS_INFRA_URL → http://agents-gateway:8000x-api-key: $AGENTS_INFRA_API_KEY{
"html": "<完整 HTML 文件>",
"width": 1080,
"height": 1080,
"format": "png",
"selector": null
}
Response: 圖片 binary
先用 write tool 將 HTML 寫入 /tmp/output.html,再執行:
jq -n --rawfile html /tmp/output.html \
'{html: $html, width: 1080, height: 1080, format: "png"}' \
> /tmp/screenshot_payload.json
curl -s -X POST "$AGENTS_INFRA_URL/screenshot" \
-H 'Content-Type: application/json' \
-H "x-api-key: $AGENTS_INFRA_API_KEY" \
-d @/tmp/screenshot_payload.json \
--output /tmp/output.png
讀取 params.json 中的 brand 設定(名稱、字體、顏色)。如果 brand/ 目錄有 identity.md,也一併讀取。
| 用途 | width | height |
|---|---|---|
| IG 貼文 | 1080 | 1080 |
| IG Story | 1080 | 1920 |
| FB 貼文 | 1200 | 630 |
| 活動海報 | 1080 | 1520 |
| 資訊圖(橫) | 1920 | 1080 |
72px,小字 24px,比例 3:1 以上60px紙張質感疊層:
<div style="position:absolute;inset:0;opacity:0.05;pointer-events:none;background-image:url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 600 600%22%3E%3Cfilter id=%22a%22%3E%3CfeTurbulence type=%22fractalNoise%22 baseFrequency=%22.65%22 numOctaves=%223%22 stitchTiles=%22stitch%22/%3E%3C/filter%3E%3Crect width=%22100%25%22 height=%22100%25%22 filter=%22url(%23a)%22/%3E%3C/svg%3E');background-repeat:repeat;background-size:200px"></div>
色塊分隔線:
<div style="width:60px;height:4px;background:#541E17;margin:16px 0;"></div>
金色裝飾線:
<div style="width:80px;height:2px;background:#C9821A;margin:12px 0;"></div>
| 類型 | 配色 |
|---|---|
| 活動宣傳 | 暖米底 + 酒紅強調 + 琥珀金裝飾 |
| 青年故事 | 暖米底 + 霧藍點綴 |
| 課程資訊 | 墨黑底 + 暖米文字 + 琥珀金強調 |
| 自然生態 | 林綠底 + 暖米文字 |
| 一般公告 | 暖米底 + 深墨文字 + 酒紅裝飾線 |
產生圖片後,不要用 message tool 發送圖片(會 400 錯誤)。
在回覆文字中另起一行寫 MEDIA: 加上檔案路徑,raise-a-bull 會自動附加圖片:
報告!行事曆畫好了,請過目~
MEDIA:/tmp/output.png
LINE 不支援本地檔案,必須透過公開 URL。使用 agents-infra CDN 上傳:
/tmp/output.pngCDN_RESPONSE=$(curl -sf -X POST "$AGENTS_INFRA_URL/upload/{instance_id}" \
-H "x-api-key: $AGENTS_INFRA_API_KEY" \
-F "file=@/tmp/output.png;filename=output.png")
CDN_URL=$(echo "$CDN_RESPONSE" | jq -r '.url')
MEDIA:$CDN_URLexec + curl 呼叫 $AGENTS_INFRA_URL/screenshot,--output /tmp/output.png$AGENTS_INFRA_URL/upload/{instance_id} 取得 CDN URL(instance_id 來自 bull.json)MEDIA:/tmp/output.pngMEDIA:$CDN_URL$AGENTS_INFRA_URL/screenshot(Header: x-api-key: $AGENTS_INFRA_API_KEY)$AGENTS_INFRA_URL/upload/{instance_id}(POST multipart, Header: x-api-key: $AGENTS_INFRA_API_KEY,instance_id 來自 bull.json)$CDN_BASE_URL(https://cdn.pwlee.xyz)<!DOCTYPE html>)<head> 內加入 Google Fonts linkborder-radius: 0(報紙美學)curl --output /tmp/output.png 存檔MEDIA:/tmp/output.png 發送圖片(Discord)MEDIA:$CDN_URL