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

接合 / 合併

將多張影像並排接合、垂直堆疊或以網格排列。支援對齊、間隙、邊框、圓角半徑以及多種縮放模式。

API 端點

POST /api/v1/tools/image/stitch

參數

參數型別必填預設值說明
directionstring"horizontal"版面方向:horizontalverticalgrid
gridColumnsinteger2當方向為 grid 時的欄數(2 至 100)
resizeModestring"fit"影像的縮放方式:fitoriginalstretchcrop
alignmentstring"center"交叉軸對齊:startcenterend
gapnumber0影像之間的間隙(像素)(0 至 1000)
bordernumber0外邊框寬度(像素)(0 至 500)
cornerRadiusnumber0套用於最終輸出的圓角半徑(0 至 500)
backgroundColorstring"#FFFFFF"背景/邊框顏色,以十六進位表示(例如 #FF0000
formatstring"png"輸出格式:pngjpegwebpavifjxl
qualitynumber90輸出品質(1 至 100)

範例請求

bash
curl -X POST http://localhost:1349/api/v1/tools/image/stitch \
  -F "[email protected]" \
  -F "[email protected]" \
  -F "[email protected]" \
  -F 'settings={"direction":"horizontal","resizeMode":"fit","gap":10,"backgroundColor":"#FFFFFF","format":"png"}'

範例回應

json
{
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/stitch.png",
  "originalSize": 1234567,
  "processedSize": 987654
}

注意事項

  • 至少需要 2 張影像。在 multipart 請求中上傳多個影像檔案。
  • 支援 HEIC、RAW、PSD 與 SVG 輸入格式(自動解碼)。
  • 縮放模式:
    • fit - 沿接合軸縮放影像以配合最小尺寸。
    • original - 保留原始尺寸(可能產生不平整的邊緣)。
    • stretch - 強制影像配合最小尺寸,不保留長寬比。
    • crop - 以覆蓋方式裁切影像以配合最小尺寸。
  • grid 模式下,儲存格大小會設為所有影像尺寸的中位數。
  • cornerRadius 會套用於整個最終輸出,而非個別影像。
  • 畫布大小受 MAX_CANVAS_PIXELS 伺服器設定限制,以防止記憶體耗盡。