图片区域提取
从图片中提取指定的矩形区域,支持自定义尺寸和位置
API 文档
请求端点
POST /zh/api/tools/image-extract-region
请求参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| imageFile | file (需要先上传) | 是 | 上传任何图片文件(JPEG、PNG、WebP、TIFF)进行区域提取 |
| extractMode | select | 是 | 选择提取方式:自定义尺寸、中心、角落或百分比 |
| width | number | 否 | 设置提取宽度。百分比模式使用1-100 |
| height | number | 否 | 设置提取高度。百分比模式使用1-100 |
| gravity | select | 否 | 选择提取区域的位置 |
| x | number | 否 | 设置提取区域的水平位置(0 = 左边缘)。用于自定义模式 |
| y | number | 否 | 设置提取区域的垂直位置(0 = 顶部边缘)。用于自定义模式 |
| format | select | 否 | 选择输出格式或保持原格式 |
| quality | number | 否 | 有损格式(JPEG、WebP)的输出质量。越高 = 质量越好但文件越大 |
文件类型参数需要先通过 POST /upload/image-extract-region 上传获取 filePath,然后将 filePath 传递给对应的文件字段。
响应格式
{
"filePath": "/public/processing/randomid.ext",
"fileName": "output.ext",
"contentType": "application/octet-stream",
"size": 1024,
"metadata": {
"key": "value"
},
"error": "Error message (optional)",
"message": "Notification message (optional)"
}
文件:
文件
AI MCP 文档
将此工具添加到您的 MCP 服务器配置中:
{
"mcpServers": {
"elysiatools-image-extract-region": {
"name": "image-extract-region",
"description": "从图片中提取指定的矩形区域,支持自定义尺寸和位置",
"baseUrl": "https://elysiatools.com/mcp/sse?toolId=image-extract-region",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}
你可以串联多个工具,比如:`https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`,最多20个。
支持 URL 文件链接或 Base64 编码作为文件参数。
如果遇见问题,请联系我们:[email protected]