{
  "tool": "图片格式转换器",
  "description": "将图片转换为指定格式（PNG、JPEG、WebP），保持原图尺寸和画质",
  "usage": {
    "endpoint": "POST /api/image-format-converter",
    "method": "POST",
    "contentType": "application/json"
  },
  "parameters": {
    "imageUrl": {
      "type": "string",
      "required": true,
      "description": "要转换的图片URL"
    },
    "targetFormat": {
      "type": "string",
      "required": true,
      "description": "目标格式",
      "options": [
        "png",
        "jpeg",
        "webp"
      ]
    },
    "bucketType": {
      "type": "string",
      "required": false,
      "default": "tempfile",
      "description": "R2存储桶类型",
      "options": [
        "file",
        "tempfile",
        "static"
      ]
    },
    "noCache": {
      "type": "boolean",
      "required": false,
      "default": false,
      "description": "跳过 R2 缓存，强制重新转换"
    }
  },
  "features": [
    "支持多种图片格式转换（PNG、JPEG、WebP）",
    "保持原图尺寸不变",
    "高质量转换（质量 100）",
    "五级回退策略提高转换成功率",
    "相同图片与格式的重复请求直接命中 R2 缓存",
    "自动上传到指定的R2存储桶",
    "智能判断是否需要转换"
  ],
  "conversionStrategy": [
    "1. @cf-wasm/photon - 边缘处理，免费且并发无上限，承接主流量（仅限小图）",
    "2. imgproxy - 自建服务，无额度限制，专接 photon 处理不了的大图",
    "3. weserv - 在线服务，源站域名被拉黑时自动跳过",
    "4. Cloudinary Fetch - 外部处理，免费版单文件 10MB 上限",
    "5. Cloudflare Images - Cloudflare 官方服务，免费额度每月 5000 次"
  ],
  "runtimeConfig": {
    "photon": {
      "maxDecodedMB": 50,
      "source": "环境变量 PHOTON_MAX_DECODED_MB"
    },
    "weserv": {
      "serviceHost": "wsrv.nl",
      "blockedSourceHosts": [
        "aiquickdraw.com"
      ]
    },
    "imgproxy": {
      "baseUrl": "https://imgproxy.aiquickdraw.com,https://imgproxy2.aiquickdraw.com",
      "endpoints": [
        "https://imgproxy.aiquickdraw.com",
        "https://imgproxy2.aiquickdraw.com"
      ],
      "missingConfig": [],
      "ready": true
    },
    "cloudinary": {
      "configured": true
    },
    "bindings": {
      "TEMPFILE_BUCKET": true,
      "FILE_BUCKET": true,
      "IMAGES": true
    }
  },
  "examples": {
    "requestParams": {
      "imageUrl": "https://example.com/image.png",
      "targetFormat": "webp",
      "bucketType": "tempfile"
    },
    "responseSuccess": {
      "success": true,
      "code": 200,
      "msg": "success",
      "data": {
        "originalUrl": "https://example.com/image.png",
        "convertedUrl": "https://tempfile.aiquickdraw.com/image-format-converter/1234567890-abc123.webp",
        "originalFormat": "png",
        "targetFormat": "webp",
        "converted": true,
        "strategy": "IMGPROXY",
        "cached": false,
        "fileInfo": {
          "fileName": "1234567890-abc123.webp",
          "fileSize": 184320,
          "mimeType": "image/webp",
          "uploadedAt": "2023-12-07T10:30:00.000Z",
          "bucketType": "tempfile"
        },
        "message": "图片格式转换成功"
      }
    },
    "curl": "curl -X POST https://your-domain.com/api/image-format-converter \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"imageUrl\": \"https://example.com/image.png\",\n    \"targetFormat\": \"webp\",\n    \"bucketType\": \"tempfile\"\n  }'"
  }
}