SwiftyImageIO
ImageIO 框架的 Swift 封装。
用法
要运行示例项目,首先克隆仓库,然后从 Example 目录运行 pod install
示例
创建缩略图
import SwiftyImageIO
let source = ImageSource(data: imageData, options: nil)
let thumbnailCGImage = source?.createThumbnail(maxPixelSize: thumbnailSize)
将图像写入磁盘
import SwiftyImageIO
import MobileCoreServices
if let imageDestination = ImageDestination(url: saveURL, UTI: kUTTypeJPEG, imageCount: 1) {
imageDestination.addImage(cgImage)
let imageSaved = imageDestination.finalize()
}
从动画 UIImage 创建 GIF
let gifMaker = GIF()
try gifMaker.makeGIF(fromAnimatedImage: animatedImage,
writeTo: savePath,
properties: GIF.Properties(loopCount: 1),
frameProperties: GIF.FrameProperties(delayTime: 0.1))
读取 GPS 图像属性
let source = ImageSource(url: jpgWithExifImageURL, options: nil)
guard let properties = source?.propertiesForImage() else {
XCTFail("We created image without properties.");
return
}
guard let gpsProperties = properties.get(GPSImageProperties.self) else {
XCTFail("GPS Not available")
return
}
测试示例
安装
CocoaPods
pod "SwiftyImageIO"
Swift 包管理器
dependencies: [
.Package(url: "https://github.com/diejmon/SwiftyImageIO.git", majorVersion: 0, minor: 4)
]
Carthage
github "diejmon/SwiftyImageIO" ~> 0.4
EXIF
EXIF值列表可在此文档中找到
作者
Alexander Belyavskiy, [email protected]
许可证
SwiftyImageIO 在MIT许可证下提供。更多详情见LICENSE文件。