{
  "name": "image",
  "title": "图片处理",
  "description": "基于sharp的图片处理工具，支持缩放、裁剪、旋转、格式转换、压缩等操作。触发关键词：图片处理、编辑图片、处理图片、图片缩放、图片裁剪",
  "category": "图形处理",
  "group": "media",
  "type": "function",
  "main": "./index.js",
  "params": [
    {
      "name": "action",
      "description": "操作类型",
      "type": "string",
      "required": true,
      "enum": ["resize", "crop", "rotate", "flip", "flop", "convert", "compress", "blur", "sharpen", "grayscale", "tint", "trim"]
    },
    {
      "name": "input",
      "description": "源图片文件路径，必须使用绝对路径",
      "type": "string",
      "required": true
    },
    {
      "name": "output",
      "description": "输出文件路径（可选，不传则自动生成）",
      "type": "string"
    },
    {
      "name": "width",
      "description": "目标宽度（像素），resize/crop操作使用",
      "type": "number"
    },
    {
      "name": "height",
      "description": "目标高度（像素），resize/crop操作使用",
      "type": "number"
    },
    {
      "name": "format",
      "description": "输出格式：jpeg/png/webp/avif/tiff/gif，convert/compress操作使用",
      "type": "string",
      "enum": ["jpeg", "jpg", "png", "webp", "avif", "tiff", "gif"]
    },
    {
      "name": "quality",
      "description": "输出质量（1-100），compress和convert操作使用，默认80",
      "type": "number",
      "default": 80
    },
    {
      "name": "angle",
      "description": "旋转角度（度数），rotate操作使用",
      "type": "number"
    },
    {
      "name": "sigma",
      "description": "模糊强度（3-1000），blur操作使用，默认10",
      "type": "number",
      "default": 10
    },
    {
      "name": "fit",
      "description": "resize的适配模式：cover(裁剪填充)/contain(等比包含)/fill(拉伸)/inside(等比缩小)/outside(等比放大)，默认cover",
      "type": "string",
      "enum": ["cover", "contain", "fill", "inside", "outside"],
      "default": "cover"
    },
    {
      "name": "withoutEnlargement",
      "description": "resize时是否禁止放大图片，设为true时只缩小不放大",
      "type": "boolean",
      "default": false
    },
    {
      "name": "background",
      "description": "旋转时的背景色，JSON对象格式如 {\"r\":255,\"g\":0,\"b\":0,\"alpha\":1}",
      "type": "object"
    },
    {
      "name": "tintColor",
      "description": "着色颜色，JSON对象格式如 {\"r\":255,\"g\":0,\"b\":0}，tint操作使用",
      "type": "object"
    },
    {
      "name": "trimThreshold",
      "description": "裁剪空白边缘的阈值（1-255），trim操作使用，默认10",
      "type": "number",
      "default": 10
    },
    {
      "name": "position",
      "description": "crop时的裁剪位置：center/top/right/bottom/left/entropy/attention，默认center",
      "type": "string",
      "default": "center"
    }
  ],
  "returns": [
    {
      "name": "code",
      "type": "number",
      "description": "操作状态代码，0表示成功",
      "default": 0
    },
    {
      "name": "msg",
      "type": "string",
      "description": "操作反馈消息"
    },
    {
      "name": "input",
      "type": "string",
      "description": "源文件路径"
    },
    {
      "name": "file_path",
      "type": "string",
      "description": "处理后文件路径"
    },
    {
      "name": "format",
      "type": "string",
      "description": "输出格式"
    },
    {
      "name": "size",
      "type": "number",
      "description": "输出文件大小（字节）"
    },
    {
      "name": "original_size",
      "type": "number",
      "description": "源文件大小（字节）"
    },
    {
      "name": "compression_ratio",
      "type": "string",
      "description": "压缩比率"
    },
    {
      "name": "width",
      "type": "number",
      "description": "目标宽度"
    },
    {
      "name": "height",
      "type": "number",
      "description": "目标高度"
    }
  ]
}
