I want to reduce image file size that take from UIImagePickerController
. I use this method
NSData *imageData = UIImageJPEGRepresentation(image, 0.1);
but it reduce 2.2 MB image file size to 300 KB I want my image file size become less than 100 KB.
How to reduce the image size in KB/MB? To reduce the image size in KB or MB online, first upload it to ResizePixel's website. Enter a desired file size and select the corresponding unit of measurement (KB or MB). Then proceed to Download page to get the image file.
Apple's docs state:
The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality).
And since the compression quality is a CGFloat, it supports decimal places beyond the tenths place. That being said, try:
NSData *imageData = UIImageJPEGRepresentation(image, 0.032);
Easiest way to reduce image size in kilos is to reduce the size in pixels! Scale it smaller:
CGFloat scaleSize = 0.2f;
UIImage *smallImage = [UIImage imageWithCGImage:image.CGImage
scale:scaleSize
orientation:image.imageOrientation];
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