photoCompress(file, obj?, cb?): void
图片压缩工具
| Name | Type | Description |
|---|---|---|
file |
File |
需要压缩的图片文件 |
obj |
Object |
压缩参数配置 |
obj.blob? |
boolean |
是否输出Blob格式 |
obj.height? |
number |
压缩后图片高度(保持比例) |
obj.quality? |
number |
图片质量(0-1之间) |
obj.width? |
number |
压缩后图片宽度(保持比例) |
cb? |
(compressed: string | Blob, original: string | Blob) => void |
压缩完成回调函数 |
void
Description
通过Canvas API实现图片压缩,支持调整尺寸、质量和输出格式
Throws
当输入参数类型不正确时抛出
Example