简体   繁体   English

如何以 MB 为单位计算 base64image 字符串大小?

[英]How to calculate base64image String size in MB?

I am taking a picture and i am converting it into Base64 string.我正在拍照,并将其转换为 Base64 字符串。 And i am able to calculate the size of the picture in KB.我能够以 KB 为单位计算图片的大小。 I need to know the formula to calculate the size in MB.我需要知道以 MB 为单位计算大小的公式。 Please clarify.请说清楚。

The below code works fine for calculating size in KB.以下代码适用于以 KB 为单位计算大小。

function onCameraClick() {
      var base64Val = kony.convertToBase64(frmImageSize.camCamera.rawBytes);
      var imageSizeinKB = base64Val.length*0.75 )/1024;        
}

For your reference:供你参考:
1024 bytes = 1 KB 1024 字节 = 1 KB
1024 KB = 1 MB 1024 KB = 1 MB
1024 MB = 1 GB 1024 MB = 1 GB
1024 GB = 1 TB 1024 GB = 1 TB

So if you have arrived result in KB, to get the result in MB please divide it by 1024.所以如果你得到了以 KB 为单位的结果,要得到以 MB 为单位的结果,请将它除以 1024。

Result in MB = result in KB/1024.以 MB 为单位的结果 = 以 KB/1024 为单位的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM