2012-01-09 55 views
0

我想从照片中获得exif。我如何做到最佳?如何从照片中获得exif?

NSData *dataOfImageFromGallery = UIImageJPEGRepresentation (workingImage,0.5); 

CGImageSourceRef imageSource; 
imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)dataOfImageFromGallery, NULL); 

if (imageSource == NULL) { 
    // Error loading image ... 
    return; } 

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:NO], (NSString *)kCGImageSourceShouldCache, nil]; 
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, (__bridge CFDictionaryRef)options); 

if (imageProperties) { 
    NSNumber *width = (__bridge NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth); 
    NSNumber *height = (__bridge NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight); 

    CFRelease(imageProperties); 

    NSLog(@"width: %@", width); 
    NSLog(@"height: %@", height); 
} 

本刊widthheight但EXIF属性是CGImageProperties.h约40 ImageIO.h库文件,我不知道怎么一下子打印。

回答

2

使用exiftool, 我simple project基于exiftool

+0

我不明白。我必须写这个函数。你给我你的应用程序。 – 2012-01-09 18:30:55

+0

对不起,我的项目基于exiftool http://owl.phy.queensu.ca/~phil/exiftool/ – SAKrisT 2012-01-09 19:38:52

0

如果你的目标IOS 4及以上的,你应该使用ALAssetsLibrary。 这里有很多线程描述ALAssetsLibrary以及如何从图像中获取EXIF数据。

要知道,虽然,如果用户不容许的定位服务APP ALAssetsLibrary不会工作,如果你想要做的是日志imageProperties的全部内容会报告错误(拒绝访问)

0

字典,然后就去做:

NSLog(@"imageProperties: %@", imageProperties);

如果这不是你要找的内容,请澄清你的问题。

相关问题