Appearance
compressImage
▸ compressImage(urls
, options?
): Promise
<{ origin
: string
; src
: string
}[]>
压缩图片
参数
Name | Type | Default value | Description |
---|---|---|---|
urls | string [] | undefined | 图片路径 |
options | Object | {} | |
options.compressHeight | number | undefined | 压缩后图片的高度,单位为px,若不填写则默认以 compressedWidth 为准等比缩放 |
options.compressedWidth | number | undefined | 压缩后图片的宽度,单位为px,若不填写则默认以 compressHeight 为准等比缩放 |
options.quality | number | 90 | 图片质量,默认 80% |
返回值
Promise
<{ origin
: string
; src
: string
}[]>
示例
ts
const [{src: compressPath}] = await compressImage(urls, {quality: 90})