Skip to content

Home > sculp-js > compressImg

compressImg() function

Web端:等比例压缩图片批量处理 (小于minFileSizeKB:50,不压缩), 支持压缩全景图或长截图

  1. 默认根据图片原始size及宽高适当地调整quality、width、height 2. 可指定压缩的图片质量 quality(若不指定则根据原始图片大小来计算), 来适当调整width、height 3. 可指定压缩的图片最大宽高 maxSize(若不指定则根据原始图片宽高来计算), 满足大屏幕图片展示的场景

Signature:

typescript
export declare function compressImg(file: File | FileList, options?: ICompressOptions): Promise<ICompressImgResult | ICompressImgResult[] | null>;

Parameters

Parameter

Type

Description

file

File | FileList

图片或图片数组

options

ICompressOptions

(Optional) 压缩图片配置项,default: {mime:'image/jpeg', minFileSizeKB: 50}

Returns:

Promise<ICompressImgResult | ICompressImgResult[] | null>

{Promise<ICompressImgResult | ICompressImgResult[] | null>}

Released under the MIT License.