This page was machine-translated. Spotted a mistake?Help improve it.
Skip to content

迷因產生器

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

API 端點

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

接受下列其中一種:

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

參數

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

文字方塊

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

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

文字版面配置的方塊 ID

版面配置可用的方塊 ID
top-bottomtopbottom
top-onlytop
bottom-onlybottom
centercenter
side-by-sideleftright

範例請求

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

bash
curl -X POST http://localhost:1349/api/v1/tools/image/meme-generator \
  -H "Authorization: Bearer si_your-api-key" \
  -F "[email protected]" \
  -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 主體,不需上傳檔案):

bash
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"}]}'

範例回應

json
{
  "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 輸入會在處理前自動解碼。