如何在iOS 4.0+中以字节为单位获取UIImage的大小?
问题描述:
我正在尝试从照片库或相机中挑选图像。
委托方法:
I am trying to pick an image from the photo library or from the camera.
The delegate method:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
给我 UIImage
对象。我需要为我的应用程序找到 bytes
中图像的大小。
Gives me the UIImage
object. I need to find the size of the image in bytes
for my application.
我有什么方法可以获得图像的文件类型以及字节大小?
Is there any way I can get the file type of the image and also the size in the bytes?
任何形式的帮助都将受到高度赞赏。
Any kind of help would be highly appreciated.
提前致谢
答
请尝试以下代码:
NSData *imageData = [[NSData alloc] initWithData:UIImageJPEGRepresentation((image), 1.0)];
int imageSize = imageData.length;
NSLog(@"SIZE OF IMAGE: %i ", imageSize);