是否可以测量/检测通过 canvas.toDataURI
方法生成的图像的大小?
我需要检测它是否大于特定大小,如果是则告诉用户它太大而无法上传。
最佳答案
我想你想要这样的东西?
http://jsfiddle.net/qb65r4Lf/
//pass string into the function...
function byteCount(s) {
return encodeURI(s).split(/%..|./).length - 1;
}
关于javascript - 检测 Canvas.toDataURL 的大小(以千字节为单位),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31980842/