我正在开发一个Apple Photos扩展。我需要从PHAsset获取照片HDR和深度效果标志。这个扩展似乎只给了我一个临时图像文件的URL,而不是对PHAsset的引用。换句话说,我需要从扩展图像URL (或其他方式)获取PHAsset的对象,这样才能获得HDR和深度效果属性。
for item: Any in self.extensionContext!.inputItems {
let inputItem = item as! NSExtensionItem
for provider: Any in inputItem.attachments! {
let itemProvider = provider as! NSItemProvider
if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeImage as String) { ......非常感谢,
皮尤什
发布于 2017-06-16 14:01:40
据我所知,深度(100%)和HDR (不确定:P)在图像属性中。因此,请执行以下操作来获取它们:
let options = PHContentEditingInputRequestOptions()
//for icloud or itunes
options.isNetworkAccessAllowed = true
//self is the PHAsset Object here this snippet is from an extenstion I made.
self.requestContentEditingInput(with: options, completionHandler: {
(contentEditingInput, _) -> Void in
if contentEditingInput != nil {
if let url = contentEditingInput?.fullSizeImageURL {
//URL is the path of the File in the
if let imageSource = CGImageSourceCreateWithURL(url, nil) {
if let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as Dictionary? {
//Now you can access the metadata here depth should be in exif afaik
}
}
}
}
}可以通过Image I/O的特定常量访问不同的元数据
https://stackoverflow.com/questions/44581253
复制相似问题