2011-05-21 89 views
2

我使用兩個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數據:

EXIF data from Preview

回答

1

嘗試從石英2D的ImageIO的框架。

CGImageSourceCopyPropertiesCGImageProperties設置爲kCGImagePropertyExifDictionary

具體要獲得2.8 VS 3的最大光圈,您可能需要設置kCGImageSourceShouldAllowFloatappropriately

這不是可可,但易於使用和xfer可可。

編輯

以上部分有關設置kCGImageSourceShouldAllowFloat是不正確......

我只是把一個F2.860毫米微距尼克爾定焦鏡頭在尼康D7000進行檢查。我拍攝了一張非常近的物體(距離3英寸),另一個處於中央焦點(6英尺),另一個處於遠處焦點處。

近距離焦點圖像EXIF報告預覽中的「最大光圈」值爲3.2。 Photoshop允許查看文件中嵌入的原始EXIF數據。如果我在Photoshop中打開近距離物體圖像,則嵌入式EXIF將顯示爲exif:MaxAperatureValue: 32/10

使用相同的方法,Mid聚焦圖像報告的「最大光圈」爲3.0(或Photoshop中爲30/10)。只有遙遠的焦點報道「最大光圈」值爲2.8。

因此,看起來相機正在報告給定焦點的當前設置的鏡頭的最大光圈有效。這是有道理的,因爲變焦最大光圈變焦鏡頭的普及。如果您在變焦鏡頭上安裝了可變最大光圈(如Nikkor 18-200 f3.5/f5.6),則在給定的變焦設置和對焦設置下的有效最大光圈由相機計算並嵌入EXIF數據。這個值通過預覽顯示並且由ImageIO框架來修正。

T-Stops

+0

不健全的權利我,因爲:(1)我已經在使用的ImageIO框架(參見我的例子代碼),雖然有不同的API調用,(2)我得到花車形成其他EXIF數據,(3)kCGImageSourceShouldAllowFloat的文檔似乎是指圖像數據,而不是EXIF數據,(4)蘋果自己的預覽應用程序也是錯誤的。不管怎樣,謝謝! – 2011-05-23 12:39:07

+0

你對MaxAperture的解釋是3而不是2.8,這是有說服力的。你能想出一些好的東西來解釋爲什麼ApertureValue從SDK和預覽中得到6,其中兩個都報告FNumber爲8,ExifTool報告爲8?另外,雖然我已經擁有了你,但從哪裏來看,ExifTool的MaxApertureValue是2.8? – 2011-05-23 20:43:20

+0

我不知道,除了說如果你看一下最近相機的原始EXIF數據,那裏可能有足夠的信息來計算和呈現基於程序員想要的任何常規的信息。蘋果會根據相機計算出來。你看過有關文件的原始EXIF數據嗎? – dawg 2011-05-23 23:32:45