ios - How to compress size of UIImage to a certain size (in KB) -


this question has answer here:

in app, have user select/take photo, goes method (standard stuff):

- (void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info 

now, how can reduce image file size (i want reduced somewhere around 80-90 kb).

a bit crude:

uiimage *image = (uiimage *)info[uiimagepickercontrollereditedimage]; nsdata *data; (cgfloat quality = 1.0; cgfloat >= 0; cgfloat -= 0.05) {     data = uiimagejpegrepresentation(image,quality);     if (data.length < 90000)         break; } 

probably quite cpu-intensive. there better ways find ideal quality more quickly.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

c# - How do I get the Nth largest element from a list with duplicates, using LINQ? -

jsp - "Sending a redirect is forbidden after the response has been committed" in sendRedirect -