I am trying to pick an image from the photo library or from the camera.
The delegate method:
- (void)imagePickerController:(UIImagePickerController *)picker d
From:@fbrereto's answer:
The underlying data of a UIImage
can vary, so for the same "image" one can have varying sizes of data. One thing you can do is use UIImagePNGRepresentation
or UIImageJPEGRepresentation
to get the equivalent NSData
constructs for either, then check the size of that.
From:@Meet's answer:
UIImage *img = [UIImage imageNamed:@"sample.png"];
NSData *imgData = UIImageJPEGRepresentation(img, 1.0);
NSLog(@"Size of Image(bytes):%d",[imgData length]);