I'm trying to get the length of a UIImage. Not the width or height of the image, but the size of the data.
UIImage *img = [UIImage imageNamed:@"sample.png"]; NSData *imgData = UIImageJPEGRepresentation(img, 1.0); NSLog(@"Size of Image(bytes):%d",[imgData length]);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With