image-crop
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImage Crop
图片裁剪
Crops an image to specified dimensions centered on a configurable focal point. The crop region is calculated to center on the focal point while staying within image bounds.
围绕可配置的焦点将图片裁剪为指定尺寸。裁剪区域会以焦点为中心计算,同时确保在图片边界范围内。
Command
命令
bash
agent-media image crop --in <path> --width <px> --height <px> [options]bash
agent-media image crop --in <path> --width <px> --height <px> [options]Inputs
输入参数
| Option | Required | Description |
|---|---|---|
| Yes | Input file path or URL |
| Yes | Width of crop area in pixels |
| Yes | Height of crop area in pixels |
| No | Focal point X position 0-100 (default: 50 = center) |
| No | Focal point Y position 0-100 (default: 50 = center) |
| No | DPI/density for output (default: 300) |
| No | Output path, filename or directory (default: ./) |
| No | Provider to use (default: local) |
| 选项 | 是否必填 | 说明 |
|---|---|---|
| 是 | 输入文件路径或URL |
| 是 | 裁剪区域的宽度(像素) |
| 是 | 裁剪区域的高度(像素) |
| 否 | 焦点X轴位置 0-100(默认值:50 = 居中) |
| 否 | 焦点Y轴位置 0-100(默认值:50 = 居中) |
| 否 | 输出文件的DPI/密度(默认值:300) |
| 否 | 输出路径、文件名或目录(默认值:./) |
| 否 | 使用的处理提供商(默认值:local) |
Output
输出
Returns a JSON object with the cropped image path:
json
{
"ok": true,
"media_type": "image",
"action": "crop",
"provider": "local",
"output_path": "cropped_123_abc.png",
"mime": "image/png",
"bytes": 45678
}返回包含裁剪后图片路径的JSON对象:
json
{
"ok": true,
"media_type": "image",
"action": "crop",
"provider": "local",
"output_path": "cropped_123_abc.png",
"mime": "image/png",
"bytes": 45678
}Examples
示例
Crop to 800x600 centered (default focal point):
bash
agent-media image crop --in photo.jpg --width 800 --height 600Crop with focal point at top-left area (20% from left, 30% from top):
bash
agent-media image crop --in photo.jpg --width 800 --height 600 --focus-x 20 --focus-y 30Crop from URL with custom output:
bash
agent-media image crop --in https://example.com/image.jpg --width 1024 --height 768 --out ./output裁剪为800x600尺寸并居中(默认焦点):
bash
agent-media image crop --in photo.jpg --width 800 --height 600将焦点设为左上角区域(距左侧20%,距顶部30%)进行裁剪:
bash
agent-media image crop --in photo.jpg --width 800 --height 600 --focus-x 20 --focus-y 30从URL获取图片并裁剪,指定自定义输出路径:
bash
agent-media image crop --in https://example.com/image.jpg --width 1024 --height 768 --out ./outputProviders
处理提供商
- local (default) - Uses Sharp library, no API key required
- local(默认)- 使用Sharp库,无需API密钥