环顾四周,无法找到明确的方法来做到这一点...... 我需要从某个URL上的图像中读取元数据。有没有办法在iPhone上做到这一点?
答案 0 :(得分:1)
答案 1 :(得分:1)
我尝试使用iphone-exif,它只是在我的项目中没有工作。很多人都遇到了和我一样的错误。
好消息是我找到了另一种解决方案......
NSDictionary *IPTCDict;
NSString *urlString = @"http://SOMEIMAGEURL.jpg";
NSMutableData *photoData = [NSMutableData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)photoData, NULL);
NSDictionary *metadata = (__bridge NSDictionary *)CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
NSLog(@"Meta: %@", metadata); //Will print out all the metadata
// Pulls out the IPTC data
IPTCDict = [metadata objectForKey:(NSString *)kCGImagePropertyIPTCDictionary];
NSLog(@"Caption: %@\nCopyright: %@", [IPTCDict objectForKey:@"Caption/Abstract"], [IPTCDict objectForKey:@"CopyrightNotice"]);