简体   繁体   English

Mac OS X 10.6 API报告错误的EXIF数据以获取光圈

[英]Mac OS X 10.6 APIs report incorrect EXIF data for aperture

I'm using two APIs to read EXIF data from images, which I'll call "valueForProperty:NSImageEXIFData" and "CGImageSourceCopyPropertiesAtIndex". 我正在使用两个API从图像读取EXIF数据,我将其称为“ valueForProperty:NSImageEXIFData”和“ CGImageSourceCopyPropertiesAtIndex”。 Both provide the same EXIF data, although the second provides other data (eg, GPS, TIFF), too. 两者都提供相同的EXIF数据,尽管第二个也提供其他数据(例如GPS,TIFF)。

Both give wrong values for "ApertureValue" and "MaxApertureValue", and the correct value for "FNumber". 两者都给出“ ApertureValue”和“ MaxApertureValue”的错误值,以及“ FNumber”的正确值。 The example program that follows dumps all of the metadata returned by each method, and also invokes ExifTool. 后面的示例程序转储每个方法返回的所有元数据,并调用ExifTool。 The output is summarized at the end. 最后总结输出。

(Knowing what lens I was using, ExifTool is correct when it reports MaxApertureValue as 2.8.) (知道我使用的是什么镜头,ExifTool将MaxApertureValue报告为2.8时是正确的。)

Details: Xcode 4.02, OS X 10.6.7, 10.6 SDK 详细信息:Xcode 4.02,OS X 10.6.7、10.6 SDK

Anyone else notice this anomaly? 还有其他人注意到这个异常吗?

#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

*/

Update: It's not me. 更新:不是我。 Here's the EXIF data as reported by Apple's Preview app: 这是Apple的预览应用程序报告的EXIF数据:

预览中的EXIF数据

Try the ImageIO framework from Quartz 2D. 尝试使用Quartz 2D的ImageIO框架。

Specifically CGImageSourceCopyProperties with CGImageProperties set to kCGImagePropertyExifDictionary 特别CGImageProperties设置为kCGImagePropertyExifDictionary的CGImageSourceCopyProperties

To get 2.8 vs 3 for the max aperture, you may need to set kCGImageSourceShouldAllowFloat appropriately . 要使最大光圈达到2.8 vs 3 ,您可能需要适当地设置kCGImageSourceShouldAllowFloat

It's not Cocoa, but easy to use and xfer to Cocoa. 它不是可可,但易于使用,可扩展到可可。

Edit 编辑

The part above about setting kCGImageSourceShouldAllowFloat is incorrect... 上面有关设置kCGImageSourceShouldAllowFloat的部分不正确...

I just put an f2.8 60mm Micro Nikkor prime lens on a Nikon D7000 to check this. 我只是在尼康D7000上放了一个f2.8 60mm Micro Nikkor定焦镜头来检查。 I took one image of a very close object (3 inches away), another at mid focus (6 feet) and a third at distant focus. 我拍摄了一张非常近的物体(3英寸远)的图像,另一幅是在中焦点(6英尺)处,第三幅是在远距焦点处。

The close focus image EXIF reported "Max Aperture" value of 3.2 in Preview. 近景图像EXIF在“预览”中报告的“最大光圈”值为3.2。 Photoshop allows the raw EXIF data embedded in the file to be seen. Photoshop允许查看嵌入在文件中的原始EXIF数据。 If I open the close object image in Photoshop, the embedded EXIF is shown as exif:MaxAperatureValue: 32/10 如果我在Photoshop中打开关闭对象图像,则嵌入式EXIF将显示为exif:MaxAperatureValue: 32/10

Using the same methods, the Mid focus image has a reported "Max Aperture"of 3.0 (or 30/10 in Photoshop). 使用相同的方法,中焦点图像的“最大光圈”报告为3.0(在Photoshop中为30/10)。 Only the distant focus reported "Max Aperture" value of 2.8. 只有远处的焦点报告“最大光圈”值为2.8。

So it would seem that the camera is reporting the effective max aperture of the lens given the current setting of the focus. 因此,考虑到当前的焦点设置,相机似乎正在报告镜头的有效最大光圈。 This makes sense, because of the prevalence of variable max aperture zoom lenses. 这是有道理的,因为存在可变最大光圈变焦镜头。 If you put a zoom lens on that has a variable max aperture (such as a Nikkor 18-200 f3.5 / f5.6) the effective max aperture at the given zoom setting and focus setting is calculated by the camera and embedded in the EXIF data. 如果将变焦镜头放在具有可变最大光圈的镜头(例如Nikkor 18-200 f3.5 / f5.6)上,则给定变焦设置和聚焦设置下的有效最大光圈将由相机计算并嵌入到EXIF数据。 This value is corrected shown by Preview and assumably by the ImageIO framework. 此值已由Preview显示,并可能由ImageIO框架显示。

See T-Stops 止动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM