How to shrink the image without affecting the quality programmatically.
After capture the image I want to reduce the size of that image without changing the quality in
I search a lot with this topic a lot. After few days, i found this one. Hope this is much faster then the accepted answer.
NSData *imageData;
imageData=[[NSData alloc] initWithData:UIImageJPEGRepresentation((chosenImage), 1.0)];
NSLog(@"[before] image size: %lu--", (unsigned long)[imageData length]);
CGFloat scale= (100*1024)/(CGFloat)[imageData length]; // For 100KB.
UIImage *small_image=[UIImage imageWithCGImage:chosenImage.CGImage scale:scale orientation:chosenImage.imageOrientation];
imageData = UIImageJPEGRepresentation(small_image, scale*1.00);
NSLog(@"[after] image size: %lu:%f", (unsigned long)[imageData length],scale);
It worked for me great!. Try it once.