简体   繁体   English

如何获得UIImage正确的文件大小

[英]How to get UIImage correct file size

When I take the picture on camera, I'd like to get file size of UIImage. 当我把相机的照片,我想获得的UIImage的文件大小。

-(void)imagePickerController:(UIImagePickerController*)imagePicker didFinishPickingMediaWithInfo:(NSDictionary*)info {
     UIImage *originalimage = [info objectForKey:UIImagePickerControllerOriginalImage];
     NSData *dataForPNGFile =  UIImagePNGRepresentation(originalimage);
     int fileLengthPNG = dataForPNGFile.length;
     NSLog(@"-->> fileSizePNG : [%i]", fileLengthPNG);
}

I wrote this code but the system console returned "fileSizePNG : [10550292]". 我编写了这段代码,但是系统控制台返回“ fileSizePNG:[10550292]”。
I think 10550292 bytes is too big. 我认为10550292字节太大。

It is about 10MB so I thought my code is mistake. 它大约有10MB,所以我认为我的代码是错误的。

If you find any problems, could you please let to me? 如果您发现任何问题,可以让我吗?

I'd [dataForPNGFile writeToFile:@"test.png" atomically:YES] 我会自动[dataForPNGFile writeToFile:@"test.png" atomically:YES]

and then go to the actual file and look at the size of the file. 然后转到实际文件并查看文件的大小。 Then you'll know for sure. 然后您将确定。

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

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