ios – 如何获取UIImage的大小(KB)

前端之家收集整理的这篇文章主要介绍了ios – 如何获取UIImage的大小(KB)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我从didFinishPickingMediaWithInfo获取图像.
UIImage *originalImage = (UIImage*)[info valueForKey:UIImagePickerControllerOriginalImage];

我想要获取Kb的图像的大小.

解决方法

UIImage *originalImage = (UIImage*)[info valueForKey:UIImagePickerControllerOriginalImage];
    NSData *imgData = UIImageJPEGRepresentation(originalImage,1); //1 it represents the quality of the image.
    NSLog(@"Size of Image(bytes):%d",[imgData length]);
    originalImage = nil;

猜你在找的iOS相关文章