小程序可用的webp转码与压缩实例
Go to file
2025-11-28 13:36:15 +08:00
pages init 2025-11-28 13:27:24 +08:00
.DS_Store init 2025-11-28 13:27:24 +08:00
.eslintrc.js init 2025-11-28 13:27:24 +08:00
app.js init 2025-11-28 13:27:24 +08:00
app.json init 2025-11-28 13:27:24 +08:00
app.wxss init 2025-11-28 13:27:24 +08:00
convert_image_to_webp.wasm init 2025-11-28 13:27:24 +08:00
img.webp 增加md 2025-11-28 13:36:15 +08:00
project.config.json init 2025-11-28 13:27:24 +08:00
project.private.config.json init 2025-11-28 13:27:24 +08:00
readme.md 增加md 2025-11-28 13:36:15 +08:00
sitemap.json init 2025-11-28 13:27:24 +08:00

尽量不要修改utils.js内的流程代码

_convert_image_to_webp(
       inputDataPtr,  // 输入数据指针
        inputData.length, // 输入数据长度
        w,  // 输入图片宽度 0表示自动计算
        h,  // 输入图片高度 0表示自动计算
        target_w,  // 转换后宽度 0表示原图宽度
        target_h,  // 转换后高度 0表示原图高度
        80,  // 压缩质量0-100
        outputSizePtr,  // 输出数据长度指针
        0, //是否保留alpha通道 仅在原始数据时生效
        0  //是否原始数据 
)

效果图 img.png