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

图像水印

将徽标或副图像作为水印叠加到基础图像上。水印相对于基础图像宽度进行缩放,并放置在角落或中心。

API 端点

POST /api/v1/tools/image/watermark-image

接受包含两个图像文件和 JSON settings 字段的 multipart 表单数据。

参数

参数类型必填默认值说明
positionstring"bottom-right"水印位置:centertop-lefttop-rightbottom-leftbottom-right
opacitynumber50水印不透明度百分比(0 到 100)
scalenumber25水印宽度占主图像宽度的百分比(1 到 100)

文件字段

字段名必填说明
file主图像/基础图像
watermark水印/徽标图像

示例请求

bash
curl -X POST http://localhost:1349/api/v1/tools/image/watermark-image \
  -H "Authorization: Bearer si_your-api-key" \
  -F "[email protected]" \
  -F "[email protected]" \
  -F 'settings={"position": "bottom-right", "opacity": 60, "scale": 20}'

示例响应

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

说明

  • 两张图像都会被验证和解码(支持 HEIC、RAW、PSD、SVG)。
  • 水印会按比例调整大小,使其宽度等于主图像宽度的 scale%。
  • 不透明度通过与 dest-in 混合合成的 alpha 蒙版应用。
  • 角落位置距图像边缘使用 20px 的内边距。
  • 如果水印图像带有透明度(例如 PNG 徽标),合成期间会保留透明度。
  • 处理前会在两张图像上自动应用 EXIF 方向。