我使用兩個API從圖像讀取EXIF數據,我將其稱爲「valueForProperty:NSImageEXIFData」和「CGImageSourceCopyPropertiesAtIndex」。兩者都提供相同的EXIF數據,儘管第二個提供了其他數據(例如,GPS,TIFF)。Mac OS X 10.6 API報告不正確的光圈EXIF數據
兩者都給出了「ApertureValue」和「MaxApertureValue」的錯誤值,以及「FNumber」的正確值。下面的示例程序轉儲每個方法返回的所有元數據,並且還調用ExifTool。最後總結了輸出。
(知道什麼我用鏡頭,ExifTool是正確的,當它報告MaxApertureValue爲2.8)。
詳細信息:Xcode的4.02,OS X 10.6.7,10.6 SDK
任何人通知這個異常?
#import "ExifTestAppDelegate.h"
@implementation ExifTestAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSString *path = @"/Users/marc/Pictures/iPadPhotos- overflow/Portfolio/MJR_20061221_0258.jpg";
NSData *data = [NSData dataWithContentsOfFile:path];
NSImage *img = [[[NSImage alloc] initWithData:data] autorelease];
NSImageRep *rep = [img bestRepresentationForRect:NSMakeRect(0, 0, 500, 500) context:nil hints:nil];
NSDictionary *exifDict = (NSDictionary *)[(id)rep valueForProperty:NSImageEXIFData];
NSLog(@"NSImageEXIFData: %@", exifDict);
CGImageSourceRef imgSource = CGImageSourceCreateWithData((CFDataRef)data, nil);
CFDictionaryRef dictRef = CGImageSourceCopyPropertiesAtIndex(imgSource, 0, nil);
NSLog(@"CGImageSourceCopyPropertiesAtIndex: %@", dictRef);
CFRelease(imgSource);
system([[NSString stringWithFormat:@"exiftool '%@'", path] UTF8String]);
}
@end
/*
2011-05-21 11:22:58.140 ExifTest[4510:903] NSImageEXIFData: {
ApertureValue = 6;
...
FNumber = 8;
...
MaxApertureValue = 3;
...
}
2011-05-21 11:22:58.154 ExifTest[4510:903] CGImageSourceCopyPropertiesAtIndex: {
...
"{Exif}" = {
ApertureValue = 6;
...
FNumber = 8;
...
MaxApertureValue = 3;
...
ExifTool Version Number : 8.51
...
F Number : 8.0
...
Aperture Value : 8.0
...
Max Aperture Value : 2.8
*/
更新:這不是我。以下是報道蘋果的預覽應用的EXIF數據:
不健全的權利我,因爲:(1)我已經在使用的ImageIO框架(參見我的例子代碼),雖然有不同的API調用,(2)我得到花車形成其他EXIF數據,(3)kCGImageSourceShouldAllowFloat的文檔似乎是指圖像數據,而不是EXIF數據,(4)蘋果自己的預覽應用程序也是錯誤的。不管怎樣,謝謝! – 2011-05-23 12:39:07
你對MaxAperture的解釋是3而不是2.8,這是有說服力的。你能想出一些好的東西來解釋爲什麼ApertureValue從SDK和預覽中得到6,其中兩個都報告FNumber爲8,ExifTool報告爲8?另外,雖然我已經擁有了你,但從哪裏來看,ExifTool的MaxApertureValue是2.8? – 2011-05-23 20:43:20
我不知道,除了說如果你看一下最近相機的原始EXIF數據,那裏可能有足夠的信息來計算和呈現基於程序員想要的任何常規的信息。蘋果會根據相機計算出來。你看過有關文件的原始EXIF數據嗎? – dawg 2011-05-23 23:32:45