Image Compress

Hi all,


I want to compress my image to less than 500kb, which may be taken from camera or gallery. I tried a lot of code in google but nothing provides a good result. Please help me out to solve this issue...

I use this and select the compression value (0.2) to adjust:


        let imageData = UIImageJPEGRepresentation(currentPhoto!, 0.2)


where currentPhoto is UIImage?


Then I use this image as needed (attach in an email, save on file, …)

Image Compress
 
 
Q