标签:ssim 图片压缩 com javascrip call draw image ali 比例
// 图片压缩,默认同比例压缩 compressImg (URL, callback) { // 生成canvas let canvas = document.createElement(‘canvas‘) let ctx = canvas.getContext(‘2d‘) let image = new Image() image.setAttribute(‘crossOrigin‘, ‘anonymous‘) image.src = URL let quality = 0.3 image.onload = () => { canvas.width = image.width canvas.height = image.height ctx.drawImage(image, 0, 0, canvas.width, canvas.height) let newImageData = canvas.toDataURL(‘image/jpeg‘, quality) callback(newImageData) } }
标签:ssim 图片压缩 com javascrip call draw image ali 比例
原文地址:https://www.cnblogs.com/liumengdie/p/10427129.html