ios - How to compress size of UIImage to a certain size (in KB) -
this question has answer here:
- convert uiimage nsdata 6 answers
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
Post a Comment