Files
SnapOtter/apps/docs/zh-TW/tools/image/meme-generator.md
T
SnapOtterandGitHub 4963ab3bbd feat(docs-i18n): translate all documentation into 20 languages
All 181 docs markdown files translated into 20 languages (apps/docs/<locale>/**). Companion to the i18n code PR; admin-merged because the file count exceeds GitHub's per-PR CI trigger limit. Validated by pnpm i18n:check (all surfaces, 0 stale/missing) and a clean all-locale docs build.
2026-07-11 13:52:47 +08:00

3.9 KiB
Raw Blame History

description, i18n_source_hash, i18n_provenance, i18n_output_hash
description i18n_source_hash i18n_provenance i18n_output_hash
使用範本或自訂圖片、樣式化文字方塊與字型選項來建立迷因。 0a4970112ca6 human b988f567631e

迷因產生器

使用內建範本或自訂圖片建立迷因。加入具有經典迷因樣式(粗體、帶外框的文字)的文字、多種版面配置預設值與字型選擇。

API 端點

POST /api/v1/tools/image/meme-generator

接受下列其中一種:

  • Multipart 表單資料,包含一個圖片檔案與一個 JSON settings 欄位(自訂圖片模式)
  • JSON 主體,包含一個 templateId(範本模式,不需上傳檔案)

參數

參數 類型 必填 預設值 說明
templateId string - 內建迷因範本 ID。若提供此值,則不需上傳圖片
textLayout string "top-bottom" 文字方塊版面配置:top-bottomtop-onlybottom-onlycenterside-by-side
textBoxes array [] 文字方塊物件陣列,包含 idtext 欄位
fontFamily string "anton" 字型:antonarial-blackcomic-sansmontserratbebas-neuepermanent-markerroboto
fontSize number auto 字型大小(像素,8 至 200)。若省略則自動計算
textColor string "#ffffff" 文字填色
strokeColor string "#000000" 文字描邊/外框顏色
textAlign string "center" 文字對齊方式:leftcenterright
allCaps boolean true 將文字轉為大寫

文字方塊

textBoxes 陣列中的每個項目應包含:

欄位 類型 說明
id string 對應版面配置的方塊識別碼(例如 "top""bottom""left""right""center"
text string 要顯示的迷因文字

文字版面配置的方塊 ID

版面配置 可用的方塊 ID
top-bottom topbottom
top-only top
bottom-only bottom
center center
side-by-side leftright

範例請求

具有頂部與底部文字的自訂圖片:

curl -X POST http://localhost:1349/api/v1/tools/image/meme-generator \
  -H "Authorization: Bearer si_your-api-key" \
  -F "file=@photo.jpg" \
  -F 'settings={"textLayout": "top-bottom", "textBoxes": [{"id": "top", "text": "When the code works"}, {"id": "bottom", "text": "On the first try"}], "fontFamily": "anton", "allCaps": true}'

使用內建範本(JSON 主體,不需上傳檔案):

curl -X POST http://localhost:1349/api/v1/tools/image/meme-generator \
  -H "Authorization: Bearer si_your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"templateId": "drake", "textBoxes": [{"id": "top", "text": "Manual testing"}, {"id": "bottom", "text": "Automated tests"}]}'

範例回應

{
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/meme-drake.png",
  "originalSize": 450000,
  "processedSize": 520000
}

注意事項

  • 必須提供 templateId 或上傳的圖片檔案。若同時提供兩者,則使用範本。
  • 範本會定義自己的文字方塊位置;使用範本時會忽略 textLayout 參數。
  • 文字會以帶有描邊外框的 SVG 呈現,營造經典迷因外觀。
  • 若未明確設定字型大小,會自動計算以符合文字方塊。
  • 空白的文字方塊會被略過(若所有方塊皆為空,則不會進行任何呈現)。
  • 使用範本時,輸出檔名會包含範本 ID(例如 meme-drake.png)。
  • HEIC、RAW、PSD 與 SVG 輸入會在處理前自動解碼。