15

我从didFinishPickingMediaWithInfo.

UIImage *originalImage = (UIImage*)[info valueForKey:UIImagePickerControllerOriginalImage];

我想以 Kb 为单位获取 Image 的大小。

4

2 回答 2

24
    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]);
    imgData = nil;
于 2013-02-19T12:29:45.990 回答
0

我认为 op 的size (kb)内存大小是originalImage,对吧?

查看malloc_sizeARC 下的用法,请参阅this

#import <malloc/malloc.h>

NSLog(@"Size of %@: %zd", NSStringFromClass([originalImage class]), malloc_size((__bridge const void *)originalImage));
于 2018-03-15T03:07:26.073 回答