⚡ 流式图片压缩

🏠 返回首页

流式传输压缩,支持 PNG、WebP、JPG 格式,可保持原格式输出

低质量 / 小文件高质量 / 大文件
📚 API 使用文档

API 端点

POST /api/compress-image-stream?format=webp&size=1200&quality=85

参数说明

参数默认值可选值
formatwebppng, webp, jpg, original
size1200500, 1200, original, 1-8192
quality851-100

cURL 示例

# 压缩为 WebP (默认)
curl -X POST \
  -H "Content-Type: image/png" \
  --data-binary @image.png \
  "http://localhost:3000/api/compress-image-stream" \
  -o output.webp

# 压缩为 PNG
curl -X POST \
  -H "Content-Type: image/jpeg" \
  --data-binary @photo.jpg \
  "http://localhost:3000/api/compress-image-stream?format=png" \
  -o output.png

# 压缩为 JPG, 500px, 质量70%
curl -X POST \
  -H "Content-Type: image/png" \
  --data-binary @image.png \
  "http://localhost:3000/api/compress-image-stream?format=jpg&size=500&quality=70" \
  -o output.jpg

# 保持原格式和原尺寸
curl -X POST \
  -H "Content-Type: image/png" \
  --data-binary @image.png \
  "http://localhost:3000/api/compress-image-stream?format=original&size=original" \
  -o output.png

特性

  • 流式传输: 分块返回数据,适合大文件
  • 多格式支持: PNG、WebP、JPG/JPEG
  • 保持原格式: format=original 自动检测
  • 自定义尺寸: 1-8192px 任意值
  • 质量控制: 1-100 可调
由 ViNano AI 提供技术支持
开源项目 •GitHub