image-convert

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Image Convert

图片格式转换

Converts an image to a different format (PNG, JPG, or WebP).
将图片转换为其他格式(PNG、JPG或WebP)。

Command

命令

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

Inputs

输入参数

OptionRequiredDescription
--in
YesInput file path or URL
--format
YesOutput format:
png
,
jpg
,
webp
--quality
NoQuality for lossy formats (1-100, default: 80)
--out
NoOutput path, filename or directory (default: ./)
--provider
NoProvider to use (default: auto-detect)
选项是否必填描述
--in
输入文件路径或URL
--format
输出格式:
png
,
jpg
,
webp
--quality
有损格式的质量参数(1-100,默认值:80)
--out
输出路径、文件名或目录(默认值:./)
--provider
使用的处理提供商(默认值:自动检测)

Output

输出结果

Returns a JSON object with the converted image path:
json
{
  "ok": true,
  "media_type": "image",
  "action": "convert",
  "provider": "local",
  "output_path": "converted_123_abc.webp",
  "mime": "image/webp",
  "bytes": 23456
}
返回包含转换后图片路径的JSON对象:
json
{
  "ok": true,
  "media_type": "image",
  "action": "convert",
  "provider": "local",
  "output_path": "converted_123_abc.webp",
  "mime": "image/webp",
  "bytes": 23456
}

Examples

示例

Convert PNG to WebP:
bash
agent-media image convert --in photo.png --format webp
Convert to high-quality JPEG:
bash
agent-media image convert --in photo.png --format jpg --quality 95
Convert with custom output directory:
bash
agent-media image convert --in image.png --format webp --out ./converted
将PNG转换为WebP:
bash
agent-media image convert --in photo.png --format webp
转换为高质量JPEG:
bash
agent-media image convert --in photo.png --format jpg --quality 95
使用自定义输出目录进行转换:
bash
agent-media image convert --in image.png --format webp --out ./converted

Providers

处理提供商

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