I want to know the size of image taken by UIImagePickerController
by camara or library. Is there any way to find that ?
Requirement is like,
If
try this:
CGFloat compression = 0.8f;
CGFloat maxCompression = 0.1f;
int maxFileSize = 1024;
UIImage *img =[UIImage imageNamed:@"anyimg.jpg"];
NSData *imageData = UIImageJPEGRepresentation(img, compression);
while ([imageData length] > maxFileSize && compression > maxCompression)
{
compression -= 0.1;
imageData = UIImageJPEGRepresentation(img, compression);
NSLog(@"%d",[imageData length]);
}
NSLog(@"image size %d",[imageData length]);
For get image size:
NSData *data_size = UIImagePNGRepresentation(yourImage);
int image_size =[data_size length];