Reputation: 1471
My application lets user take a picture with default camera on iPhone and send it to a server. Before sending it I would like to check the image size and let's say if the size is larger than 500 KB I would let the user know filesize is too big and would not send it. Is there a way to check the image size programmatically? Help would be appreciated.
Upvotes: 0
Views: 956
Reputation: 3751
If you convert it to NSData
, you can check the length
property. The file size in MB is bytes divide by 2^20.
To convert to NSData use UIImagePNGRepresentation()
UIImage *myImage = ...
NSData *imageData = UIImagePNGRepresentation(myImage);
Upvotes: 2