图片压缩处理
来源:互联网 发布:双四选一数据选择器 编辑:程序博客网 时间:2024/06/06 13:23
import Foundationimport UIKitextension UIImage { //compress image to quality(0,1) class func compressImageToQuality(image:UIImage, quality:CGFloat) -> UIImage { if quality >= 1 || quality <= 0 { return image } //compress image data let imageData = UIImageJPEGRepresentation(image, quality) if let data = imageData { return UIImage(data: data)! } return image } //compress image to scale size class func scaleImageToSize(image:UIImage, size:CGSize) -> UIImage { let width = size.width let height = size.height if width == 0 || height == 0 { return image } //Create a graphics image context with new size UIGraphicsBeginImageContext(size) //draw scale image in rect image.drawInRect(CGRect(x: 0, y: 0, width: width, height: height)) //get the scale image from the context let scaleImage = UIGraphicsGetImageFromCurrentImageContext() //remove the current context from the top of the stack UIGraphicsEndImageContext() return scaleImage }}
0 0
- 图片处理--压缩图片
- 图片压缩处理
- 图片上传压缩处理
- 图片压缩处理
- Java图片压缩处理
- 图片上传压缩处理
- Thumbnailator(图片压缩处理)
- java处理压缩图片
- C#图片压缩处理
- 图片上传压缩处理
- Java图片压缩处理
- java压缩图片处理
- iOS图片压缩处理
- 图片压缩处理
- iOS图片压缩处理
- Android图片压缩处理
- Java图片压缩处理
- iOS压缩图片处理
- 一些提高用户体验的前端技术
- html 文本提示值
- 选择排序
- sbt 区分多个环境
- iOS应用内付费(IAP)开发步骤列表
- 图片压缩处理
- Linux后台运行nohup,setsid
- DMA基本概念及linux2440下DMA驱动程序编写与测试
- property中的strong 、weak、copy 、assign 、retain 、unsafe_unretained 与autoreleasing区别和作用详解
- CentOS如何挂载硬盘※※※※ ---持续跟进文章
- Spring事务嵌套
- git命令查看版本记录
- 'Webdings' 的字体对照表
- 每天一种算法--选择排序