KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I took a 13.3MB image and added it to XCode. I'm aware that when compiling, XCode performs some tricks to bring down the file size. I did this, to test how big the image now was, after being converted into data: UIImage *image = [UIImage imageNamed:@"image.jpg"]; NSData *data = UIImageJPEGRepresentation(image, 1.0); NSLog(@"length: %i", data.length); The length I got back was 26758066 . If that's in bytes, then it reads to me as 26.7MB. How is the image so big suddenly? Is there another way for me to get the image in data form without going through UIImage first? EDIT: Further testing reveals that this works, and brings out a data length of ~13.3MB - the expected amount: NSString *filePath = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:filePath]; NSLog(@"length: %i", data.length);
Tags (comma-separated)
Save Edits
Cancel