I would like to apply a filter to a photo from the user's library then write it back to disk. I'm using UIImageJPEGRepresentation
. This function takes a UIImage
and a compressionQuality
value between 0.0 and 1.0. Because I want to preserve the original quality, I set it to 1.0. But I found this actually creates an image file that's larger in file size than the original, somewhat significantly larger even. I noticed in Apple's Sample Photo Editing Extension app they always set the quality to 0.9. I tried that and it does output a file size close to the original photo file size. This doesn't make sense to me. Can someone explain this? Is it appropriate to always use 0.9? Does the iOS camera compress it using that value and thus 0.9 is the original quality? Or why isn't 0.9 actually 1.0, if there's nothing that's better quality?
NSData *renderedJPEGData = UIImageJPEGRepresentation(image, 0.9f);