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

拼貼 / 網格

使用 25+ 種範本將多張圖片組合成精美的網格拼貼。支援 2-9 張圖片的版面配置,並可自訂間距、圓角半徑、背景顏色,以及每格的平移/縮放控制。

API 端點

POST /api/v1/tools/image/collage

參數

參數類型必填預設值說明
templateIdstring-範本版面配置 ID(例如 2-h-equal3-left-large4-grid9-grid
cellsarray-每格設定的陣列,含 imageIndexpanXpanYzoomobjectFit
cells[].imageIndexinteger-要放入此格的圖片索引(從 0 開始)
cells[].panXnumber0水平平移偏移量(-100 至 100)
cells[].panYnumber0垂直平移偏移量(-100 至 100)
cells[].zoomnumber1縮放層級(1 至 10)
cells[].objectFitstring"cover"圖片如何填滿格子:covercontain
gapnumber8格子之間的間距(像素,0 至 500)
cornerRadiusnumber0每格的圓角半徑(像素,0 至 500)
backgroundColorstring"#FFFFFF"背景顏色,以十六進位表示或 "transparent"
aspectRatiostring"free"畫布長寬比:free1:14:33:216:99:164:5
outputFormatstring"png"輸出格式:pngjpegwebpavifjxl
qualitynumber90輸出品質(1 至 100)

可用範本

範本 ID圖片數版面配置
2-h-equal2兩個相等的欄
2-v-equal2兩個相等的列
2-h-left-large2左 2/3,右 1/3
2-h-right-large2左 1/3,右 2/3
3-left-large3左邊大圖,右邊兩張堆疊
3-right-large3左邊兩張堆疊,右邊大圖
3-top-large3上方大圖,下方兩欄
3-h-equal3三個相等的欄
3-v-equal3三個相等的列
4-grid42x2 網格
4-left-large4左邊大圖,右邊三張堆疊
4-top-large4上方大圖,下方三欄
4-bottom-large4上方三欄,下方大圖
5-top2-bottom35上方兩張,下方三張
5-top3-bottom25上方三張,下方兩張
5-left-large5左邊大圖,右邊四張堆疊
5-center-large5中央大圖,四角圍繞
6-grid-2x362 欄 x 3 列
6-grid-3x263 欄 x 2 列
6-top-large6上方大圖,下方五欄
7-mosaic7馬賽克版面配置
8-mosaic8馬賽克版面配置
9-grid93x3 網格

範例請求

bash
curl -X POST http://localhost:1349/api/v1/tools/image/collage \
  -F "[email protected]" \
  -F "[email protected]" \
  -F "[email protected]" \
  -F "[email protected]" \
  -F 'settings={"templateId":"4-grid","gap":12,"cornerRadius":8,"backgroundColor":"#F5F5F5","outputFormat":"png","quality":90}'

範例回應

json
{
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/collage.png",
  "originalSize": 2456789,
  "processedSize": 1823456
}

備註

  • 在 multipart 請求中上傳多個圖片檔案。圖片會依上傳順序指派到範本格子。
  • 若上傳的圖片數量超過範本所支援的數量,多餘的圖片會被忽略。
  • 支援 HEIC、RAW、PSD 與 SVG 輸入格式(自動解碼)。
  • 畫布基準尺寸為最長邊 2400px,並依所選長寬比縮放。
  • aspectRatio"free" 時,畫布預設為 4:3(2400x1800)。
  • 每格的 panX/panY 值會在格子內平移裁切視窗。值為 100 表示完全移到一側邊緣,-100 則移到另一側。
  • "transparent" 背景顏色僅在 pngwebpavif 輸出格式下才會保留。