compressImage 图片压缩

compressImage ^6.8

图片压缩

#请求参数

Prop Type Comment
src String 图片文件路径(相对路径)
quality Number 质量,0-100,默认值 80
target String 压缩结果,图片文件路径

#引入接口模块

import bridge from '@minix-iot/etsbridge-sdk'

#参数代码示例

let params = {
  src: 'filename.txt',
  quality: 80,
  src: 'compress/test.jpg',
}

#接口调用示例

let params = { src: this.src, quality: this.quality, target: this.target } //压缩接口参数
bridge
  .compressImage(params)
  .then((res) => {
    console.log(res)
  })
  .catch((err) => {
    console.log(err)
  })

#返回参数

  • 成功时返回
Prop Type Value
code Number 0
msg String -
  • 失败时返回
Prop Type Value Comment
code Number -12 文件操作失败
msg String

#返回示例

{
    "tempFilePath": "compress/test.jpg",
    "code": 0
}

#FAQ

tip

一次只能压缩一张图片

posted on 2024-12-27 09:32  AtlasLapetos  阅读(5)  评论(0)    收藏  举报