我正在开发Apple Photos Extension。我需要从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) { ......
非常感谢你,
的Piyush
答案 0 :(得分:0)
据我所知深度(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
的特定常量访问不同的Metadatas