怎么可以获得图片的大小? (不是尺寸!)How can I get the size of the picture? (Not the size!)
怎么可以获得图片的大小? (不是尺寸!)When imgseccheck is called, the image size is limited to 1m, so the front end wants to check whether the image exceeds 1m before calling. If it exceeds 1m, it will be used wx.compressImage Interface to compress pictures proportionally. So the question is, how can we get the size of the image? I checked it and didn't find it. This image is not selected or photographed. It is exported through canvas
回答:
wx.chooseImage的success回调函数中的res.tempFiles是上传图片本地临时文件列表,里面有size属性
选择图片的时候,返回了本地临时文件的大小,单位B
原文出处:怎么可以获得图片的大小? (不是尺寸!)
uni.downloadFile({
url: '图片地址',
success (bigRes) { console.log(bigRes) wx.getFileInfo({ filePath: bigRes.tempFilePath, success (res) { console.log(res.size) console.log(res.digest) } }) }, fail (err) { console.log('err', err) } })