【发布时间】:2011-07-04 18:19:15
【问题描述】:
我在 iOS 4.1 中使用新的 ImageIO 框架。我使用以下方法成功检索了 exif 元数据:
CFDictionaryRef metadataDict = CMGetAttachment(sampleBuffer, kCGImagePropertyExifDictionary , NULL);
读出来,它似乎是有效的。将图像保存出来是可行的,但图像中永远没有任何 exif 数据。
CGImageDestinationRef myImageDest = CGImageDestinationCreateWithURL((CFURLRef) docurl, kUTTypeJPEG, 1, NULL);
// Add the image to the destination using previously saved options.
CGImageDestinationAddImage(myImageDest, iref, NULL);
//add back exif
NSDictionary *props = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:.1], kCGImageDestinationLossyCompressionQuality,
metadataDict, kCGImagePropertyExifDictionary, //the exif metadata
nil];
//kCGImagePropertyExifAuxDictionary
CGImageDestinationSetProperties(myImageDest, (CFDictionaryRef) props);
// Finalize the image destination.
bool status = CGImageDestinationFinalize(myImageDest);
【问题讨论】:
-
保存到用户照片库时,4.1 中存在自定义 EXIF 数据的错误。保存到您的沙盒应该可以。
-
这个其实是保存到Documents目录下的,我是用4.2和4.3建的,同样的问题。很可能我在代码中做错了什么,但我还没有确定那是什么。
-
嗨,我有一个类似的问题,我快速浏览了一下。我无法解决你的问题,但我通过加载我知道设置了 kCGImageDestinationLossyCompressionQuality 的图像(或者在我的情况下为 GPS)并查看元数据字典来解决我的问题。这样,当我去保存它时,我可以确保我的结构具有相同的结构,因为如果 iOS 不喜欢该结构,它似乎不会保存 EXIF。另外,我注意到 kCGImageDestinationLossyCompressionQuality = "kCGImageDestinationLossyCompressionQuality"。看起来很奇怪?
标签: iphone macos core-graphics exif javax.imageio