document.write("");

html canvas 图片压缩后 透明背景变成黑色

 

错误写法(这种写法固定死了类型,会不匹配):

const data = canvas.toDataURL('image/jpeg', quality);

  

调整成:

let fileType = xxxObj.type

const data = canvas.toDataURL(fileType, quality);

  

 

posted @ 2024-05-14 08:59  人间春风意  阅读(141)  评论(0)    收藏  举报