image-resize

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Image Resize

图像尺寸调整

Resizes an image to a target width or height while optionally maintaining aspect ratio.
将图像调整为目标宽度或高度,可选择保持宽高比。

Command

命令

bash
agent-media image resize --in <path> [options]
bash
agent-media image resize --in <path> [options]

Inputs

输入参数

OptionRequiredDescription
--in
YesInput file path or URL
--width
NoTarget width in pixels
--height
NoTarget height in pixels
--out
NoOutput path, filename or directory (default: ./)
--provider
NoProvider to use (default: auto-detect)
At least one of
--width
or
--height
must be specified.
选项是否必填描述
--in
输入文件路径或URL
--width
目标宽度(像素)
--height
目标高度(像素)
--out
输出路径、文件名或目录(默认值:./)
--provider
使用的处理提供商(默认值:自动检测)
必须指定
--width
--height
中的至少一个。

Output

输出

Returns a JSON object with the resized image path:
json
{
  "ok": true,
  "media_type": "image",
  "action": "resize",
  "provider": "local",
  "output_path": "resized_123_abc.png",
  "mime": "image/png",
  "bytes": 45678
}
返回包含调整后图像路径的JSON对象:
json
{
  "ok": true,
  "media_type": "image",
  "action": "resize",
  "provider": "local",
  "output_path": "resized_123_abc.png",
  "mime": "image/png",
  "bytes": 45678
}

Examples

示例

Resize to 800px width:
bash
agent-media image resize --in photo.jpg --width 800
Resize to exact dimensions:
bash
agent-media image resize --in photo.jpg --width 1024 --height 768
Resize with custom output:
bash
agent-media image resize --in image.png --width 500 --out ./resized
调整为800像素宽度:
bash
agent-media image resize --in photo.jpg --width 800
调整为精确尺寸:
bash
agent-media image resize --in photo.jpg --width 1024 --height 768
自定义输出路径调整尺寸:
bash
agent-media image resize --in image.png --width 500 --out ./resized

Providers

处理提供商

  • local (default) - Uses sharp library, no API key required
  • local(默认)- 使用sharp库,无需API密钥