swift - 从 NSImage 读取 EXIF 数据
问题描述
我有一个快速的 macOS 应用程序,我一直在使用它从磁盘上的照片中读取 EXIF 元数据。使用以下代码段效果很好
let photoURL = NSURL(fileURLWithPath: imageFilename.path)
if let imageSource = CGImageSourceCreateWithURL(photoURL,nil) {
if let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as Dictionary? {// Grab all of the properties ! replaced with ?
if let exifDict = imageProperties[kCGImagePropertyExifDictionary]
我现在希望能够从存储在我的应用程序资产中的 NSImage 中读取 EXIF 数据
我有可以访问图像的代码
let myphoto = NSImage(named:NSImage.Name(rawValue: "myPhoto"))
我只是不知道如何在 NSImage 和获取 CGImageSource 之间架起桥梁,所以我可以访问 EXIF 字典
解决方案
推荐阅读
- sql-server - 使用存储在 table1 中的列名从 table2 中检索数据
- rust - 只需要 TryFrom 的 From 的要求
- javascript - Bootstrap 5 offcanvas 错误:未捕获的 TypeError:无法读取未定义的属性“parentNode”
- xcode - AppleTV:无法在设备上启动远程服务
- java - java spring boot中调用外部服务时找不到证书链
- excel - 尝试从 SharePoint URL 下载文件并打开时出错
- python - Python/Pandas:用于迁移的 .CSV 数据清理
- mongodb - 即使 {new:true} 已通过 findOneAndUpdate 也会返回旧文档
- asp.net-mvc-5 - ASP .NET MVC,“上下文”在哪里实例化
- javascript - 如何将我的基于 javascript/React Native 的应用程序转换为 .ipa 进行部署?