1
haosxianr Sep 6, 2015 via iPhone
用 CoreImage 把图片尺寸调低试试
|
2
sfz97308 Sep 6, 2015 这种需求,直接打回去不给做。不谈图片分辨率只要求文件大小的压缩都是耍流氓。
|
4
fghfjujiber Sep 6, 2015
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 希望能帮到你。 |
5
hohoho Sep 6, 2015 via iPhone
先等比例缩放图片 size ,然后再用四楼的方法循环压缩。
|
6
pubby Sep 6, 2015
|
7
xi_lin Sep 6, 2015
在小内存机型上压大图片直接用 UIImageJPEGRepresentation 有可能会死得很惨。。
推荐 https://gist.github.com/jder/4331450#file-downscaling-alassets |
8
zioc OP @fghfjujiber 正在用这个方法。有问题:
1.这个方法不一定能压到指定以下 2. UIImageJPEGRepresentation 有时会越压越大 3. 我先等比缩放图片, UIImageJPEGRepresentation 有时会还原图片分辨率大小 @hohoho |
9
kobe1941 Sep 7, 2015
@fghfjujiber 我之前也这么干过,然后有些长图清晰度不好,就把需求改了,以压缩比率优先,图片大小不管啦! JPEG 的压缩算法真的很不错的
|