gpt4 book ai didi

swift - 使用 Apple Photos SDK 读取/写入标签或关键字

转载 作者:行者123 更新时间:2023-11-28 14:04:39 25 4
gpt4 key购买 nike

有人知道 Apple 的照片 SDK 是否允许我们获取甚至修改存储在用户照片库中的 Assets 标签吗?

从官方文档我了解到 SDK 允许我们更改“收藏夹”状态、显示/隐藏 Assets ,甚至找到 Assets 的位置,但我找不到提取照片标签(关键字)的方法由 macOS 照片应用存储。

这是当前 Photos SDK 缺少的功能,还是我可以通过任何方式访问这些元数据?

谢谢

最佳答案

这是一个示例,您可以如何使用 CIImage.properties 获取元数据来自 PHAsset

fileprivate extension PHAsset {
func printMetadata() {
let options = PHContentEditingInputRequestOptions()

requestContentEditingInput(with: options) { (contentEditingInput: PHContentEditingInput?, _) -> Void in
let img = CIImage(contentsOf: contentEditingInput!.fullSizeImageURL!)
print(img?.properties)
}
}
}

对于 iCloud 存储的图像添加以下行:

options.isNetworkAccessAllowed = true

我也没有在 PHAsset 中找到图像元数据。

要编写 CIImage 元数据,您可以尝试使用 CIImage.settingProperties(_:) 方法。

关于swift - 使用 Apple Photos SDK 读取/写入标签或关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53121265/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com