iOS 对图片进行压缩
2017-03-11 19:41
260 查看
https://segmentfault.com/q/1010000000701850
- (UIImage *)compressImage:(UIImage *)image toMaxFileSize:(NSInteger)maxFileSize { CGFloat compression = 0.9f; CGFloat maxCompression = 0.1f; NSData *imageData = UIImageJPEGRepresentation(image, compression); while ([imageData length] > maxFileSize && compression > maxCompression) { compression -= 0.1; imageData = UIImageJPEGRepresentation(image, compression); } UIImage *compressedImage = [UIImage imageWithData:imageData]; return compressedImage; }
相关文章推荐
- IOS获取图片进行压缩
- iOS从相册选择图片进行压缩
- iOS开发有用代码(有判断邮箱格式是否正确的代码、图片压缩、亲测可用的图片上传代码和实现点击图片进行跳转的代码等。)
- iOS 对图片进行压缩处理
- iOS 对图片进行压缩
- iOS 使用AFN 进行单图和多图上传 摄像头/相册获取图片,压缩图片
- ios 对图片进行压缩
- 对图片进行压缩
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- 上传图片进行压缩保存
- java中对图片进行压缩以及放大。
- IOS学习笔记39——拍照、从相册选图并对图片进行裁剪
- 使用ImageMagick如何对图片进行全面压缩
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- IOS 对UIImage图片进行缩放
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- 【iphone开发】ios 从摄像头/相册获取图片,压缩图片,上传服务器小结