您可以使用 Apple 自己的 API 来获取图像 Exif。
这是 CGImageSource 参考
和CGimageProperties
她是一个简单的例子:
NSURL *imageFileURL = [NSURL fileURLWithPath:@"/Users/USERNAME/Documents/tasting_menu_004.jpg"];
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)imageFileURL, NULL);
NSDictionary *treeDict;
NSMutableString *exifData;
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], (NSString *)kCGImageSourceShouldCache,
nil];
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, ( CFDictionaryRef)options);
CFRelease(imageSource);
if (imageProperties) {
treeDict = [NSDictionary dictionaryWithDictionary:(NSDictionary*)(imageProperties)];
id exifTree = [treeDict objectForKey:@"{Exif}"];
exifData = [NSMutableString stringWithString:@""];
for (NSString *key in [[exifTree allKeys] sortedArrayUsingSelector:@selector(compare:)])
{
NSString* locKey = [[NSBundle bundleWithIdentifier:@"com.apple.ImageIO.framework"] localizedStringForKey:key value:key table: @"CGImageSource"];
id value = [exifTree valueForKey:key] ;
[exifData appendFormat:@"key =%@ ; Value = %@ \n", locKey,value];
}
NSLog(@" exifData %@", exifData);
日志 -->exifData
键=光圈值;值 = 4.643856
键=色彩空间;值 = 65535
键=自定义渲染;值 = 0
键=日期时间数字化;值 = 2013:06:13 08:35:07
键=日期时间原始;值 = 2013:06:13 08:35:07
键 =Exif 版本;值 = ( 2, 2, 1 )
键=曝光偏差值;值 = 0
键=曝光模式;值 = 1
键=曝光程序;值 = 1
键=曝光时间;值 = 0.0125
键 =FNumber ; 值 = 5
键=闪光;值 = 9
键=焦距;值 = 17
键=焦平面分辨率单元;值 = 2
键=焦平面X分辨率;值 = 3849.211788896504
键=焦平面Y分辨率;值 = 3908.141962421712
键 =ISO 速度等级;价值 = ( 800 )
键=最大光圈值;值 = 4
键=测光模式;值 = 5
键=像素 X 尺寸;值 = 5181
键=像素Y尺寸;值 = 3454
key =场景捕捉类型;值 = 0
键=快门速度值;值 = 6.321928
键=主体距离;值 = 1.22
键=亚秒时间数字化;值 = 25
key =亚秒时间原始;值 = 25
键=白平衡;值 = 0