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

旋轉與翻轉

將圖片旋轉任意角度,以及/或水平或垂直翻轉。旋轉與翻轉操作可在單一請求中結合使用。

API 端點

POST /api/v1/tools/image/rotate

接受 multipart 表單資料,包含一個圖片檔案與一個 JSON settings 欄位。

參數

參數類型必填預設值說明
anglenumber0旋轉角度(度,順時針)。接受任意數值。
horizontalbooleanfalse水平翻轉圖片(鏡像)
verticalbooleanfalse垂直翻轉圖片

範例請求

順時針旋轉 90 度:

bash
curl -X POST http://localhost:1349/api/v1/tools/image/rotate \
  -H "Authorization: Bearer si_your-api-key" \
  -F "[email protected]" \
  -F 'settings={"angle": 90}'

水平翻轉:

bash
curl -X POST http://localhost:1349/api/v1/tools/image/rotate \
  -H "Authorization: Bearer si_your-api-key" \
  -F "[email protected]" \
  -F 'settings={"horizontal": true}'

同時旋轉與翻轉:

bash
curl -X POST http://localhost:1349/api/v1/tools/image/rotate \
  -H "Authorization: Bearer si_your-api-key" \
  -F "[email protected]" \
  -F 'settings={"angle": 45, "vertical": true}'

範例回應

json
{
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/photo.jpg",
  "originalSize": 2450000,
  "processedSize": 2480000
}

注意事項

  • 會先套用旋轉,接著進行翻轉操作。
  • 非 90 度的旋轉(例如 45 度)會擴大畫布以容納旋轉後的圖片,並依輸出格式填入透明或黑色。
  • 常見數值:90、180、270 用於四分之一圈旋轉。
  • 處理前會自動套用 EXIF 方向,因此旋轉是相對於視覺方向。