|  |      1haosxianr      2015-09-06 17:26:54 +08:00 via iPhone 用 CoreImage 把图片尺寸调低试试 | 
|  |      2sfz97308      2015-09-06 18:11:24 +08:00  1 这种需求,直接打回去不给做。不谈图片分辨率只要求文件大小的压缩都是耍流氓。 | 
|      3zioc OP @sfz97308 分辨率有需求。。。 只是 UIImageJPEGRepresentation 是按质量压缩,无法控制图片文件大小。 | 
|  |      4fghfjujiber      2015-09-06 18:26:28 +08:00 CGFloat compression = 0.9f; CGFloat maxCompression = 0.1f; int maxFileSize = 250*1024; NSData *imageData = UIImageJPEGRepresentation (yourImage, compression ); while ([imageData length] > maxFileSize && compression > maxCompression ) { compression -= 0.1; imageData = UIImageJPEGRepresentation (yourImage, compression ); } ref: http://stackoverflow.com/questions/9506871/image-compression-by-size-iphone-sdk 希望能帮到你。 | 
|  |      5hohoho      2015-09-06 18:32:46 +08:00 via iPhone 先等比例缩放图片 size ,然后再用四楼的方法循环压缩。 | 
|  |      6pubby      2015-09-06 18:59:13 +08:00 | 
|  |      7xi_lin      2015-09-06 23:44:12 +08:00 在小内存机型上压大图片直接用 UIImageJPEGRepresentation 有可能会死得很惨。。 推荐 https://gist.github.com/jder/4331450#file-downscaling-alassets | 
|      8zioc OP @fghfjujiber  正在用这个方法。有问题: 1.这个方法不一定能压到指定以下 2. UIImageJPEGRepresentation 有时会越压越大 3. 我先等比缩放图片, UIImageJPEGRepresentation 有时会还原图片分辨率大小 @hohoho | 
|  |      9kobe1941      2015-09-07 10:15:49 +08:00 @fghfjujiber 我之前也这么干过,然后有些长图清晰度不好,就把需求改了,以压缩比率优先,图片大小不管啦! JPEG 的压缩算法真的很不错的 |