First resize the image with below method:
- (UIImage *)resizeImage:(UIImage*)image newSize:(CGSize)newSize {
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
call this by:
UIImage *newImage=yourImage;
CGSize size=CGSizeMake(newImage.size.width/8,newImage.size.height/8);
newImage=[self resizeImage:newImage newSize:size];
And finally compressed your image as required:
NSData *imageData = UIImageJPEGRepresentation(newImage, 0.5);
NSLog(@"Size of image = %lu KB",(imageData.length/1024));