【发布时间】:2017-07-26 06:10:04
【问题描述】:
我正在尝试从 360° jpeg 文件中获取 xmp 元数据信息。所以,我写了这段代码,但我没有得到 xmp 信息:
UIImage *img = [UIImage imageNamed:@"park_2048.jpg"];
NSData *imagedata = UIImageJPEGRepresentation(img, 1);
CGImageSourceRef source = CGImageSourceCreateWithData( (CFDataRef) imagedata, NULL);
CFDictionaryRef dictRef = CGImageSourceCopyMetadataAtIndex(source, 0, NULL);
NSDictionary* metadata = (__bridge NSDictionary *)dictRef;
NSLog(@"metadata = %@", metadata);
我也收到了警告:Incompatible pointer types initializing 'CFDictionaryRef' (aka 'const struct __CFDictionary *') with an expression of type 'CGImageMetadataRef _Nullable' (aka 'const struct CGImageMetadata *')
请帮忙
【问题讨论】:
-
CGImageSourceCopyMetadataAtIndex()返回CGImageMetadataRef。应该如何转换为CFDictionaryRef?这就是你收到警告的原因。也许是CGImageMetadataRef metadaRef = CGImageSourceCopyMetadataAtIndex(source, 0, NULL); NSArray *metadata = CFBridgingRelease(CGImageMetadataCopyTags(metadata));而不是字典(来源:stackoverflow.com/questions/25589118/…) -
谢谢,我改成了 CGImageMetadataRef 但我没有得到所有的元数据,只有我得到了这个:
(exif:PixelYDimension = 1024 exif:PixelXDimension = 2048 tiff:Orientation = 1 exif:ColorSpace = 1) -
如果要保留所有元数据,则需要将文件数据对象作为数据读取,而不是作为 UIImage。我通过使用这个想法解决了。所以我得到了所有的元数据。
标签: ios objective-c uiimage xmp