SwiftyImageIO

Swift SPM Ready Version License Platform Carthage compatible

围绕 ImageIO 框架的 Swift 封装。

用法

要运行示例项目,首先克隆 repo,然后从 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 Package Manager

dependencies: [
    .Package(url: "https://github.com/diejmon/SwiftyImageIO.git", majorVersion: 0, minor: 4)
]

Carthage

github "diejmon/SwiftyImageIO" ~> 0.4

EXIF

可以在此文档中找到 exif 值的列表

作者

Alexander Belyavskiy, diejmon@gmail.com

许可证

SwiftyImageIO 在 MIT 许可证下可用。 有关更多信息,请参见 LICENSE 文件。