I would like to save a UIImage to a CoreData Entity.
Per accepted answer here, in order to save this UIImage to the same Entity Table, suggested size of UIImage should be < 100kb
Thus when user takes a UIImage from a UIImagePickerController (either library or camera), I would like to do a UIImageJPEGRepresentation
@ CompressionQuality
rate that would render this UIImage data < 100kb
Playing around with
let imgData: NSData = UIImageJPEGRepresentation(CameraImage, <#compressionQuality: CGFloat#>)
let size = imgData.length
I've realized that 0.8 is not equivalent to 80% Data size of 1.0 compression.
How could I take any UIImage of any size and compress it down to data: with a size of 100kb maximum, so that as much integrity is held while allowing the size to be small enough to store in CoreData Entity?
NOTE: my original idea was to test size
of UIImage then compress it @ "rate X = 100,000/size"