Mac OS X 10.6 API 报告光圈的 EXIF 数据不正确

发布于 2024-11-08 12:59:20 字数 2079 浏览 3 评论 0原文

我使用两个 API 从图像中读取 EXIF 数据,我将其称为“valueForProperty:NSImageEXIFData”和“CGImageSourceCopyPropertiesAtIndex”。两者都提供相同的 EXIF 数据,尽管第二个也提供其他数据(例如 GPS、TIFF)。

两者都给出了“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

*/

更新:这不是我。以下是 Apple 预览应用程序报告的 EXIF 数据:

预览中的 EXIF 数据

I'm using two APIs to read EXIF data from images, which I'll call "valueForProperty:NSImageEXIFData" and "CGImageSourceCopyPropertiesAtIndex". Both provide the same EXIF data, although the second provides other data (e.g., GPS, TIFF), too.

Both give wrong values for "ApertureValue" and "MaxApertureValue", and the correct value for "FNumber". The example program that follows dumps all of the metadata returned by each method, and also invokes ExifTool. The output is summarized at the end.

(Knowing what lens I was using, ExifTool is correct when it reports MaxApertureValue as 2.8.)

Details: 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:

EXIF data from Preview

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的影子我的梦 2024-11-15 12:59:20

尝试 Quartz 2D 中的 ImageIO 框架。

具体来说 CGImageSourceCopyPropertiesCGImageProperties< /a> 设置为 kCGImagePropertyExifDictionary< /a>

要获得 2.83 的最大光圈,您可以需要设置 kCGImageSourceShouldAllowFloat 适当

它不是 Cocoa,但易于使用并且类似于 Cocoa。

编辑

上面关于设置kCGImageSourceShouldAllowFloat的部分是不正确的...

我刚刚在尼康D7000上安装了一个f2.8 60mm微距尼克尔定焦镜头来检查这一点。我拍摄了一张非常近的物体(3 英寸远)的图像,另一张在中焦(6 英尺)处拍摄,第三张在远焦处拍摄。

近焦图像 EXIF 在预览中报告的“最大光圈”值为 3.2。 Photoshop 允许查看文件中嵌入的原始 EXIF 数据。如果我在 Photoshop 中打开近距离物体图像,嵌入的 EXIF 将显示为 exif:MaxAperatureValue: 32/10

使用相同的方法,中焦图像的报告“最大光圈”为 3.0(或30/10 在 Photoshop 中)。仅远焦报告的“最大光圈”值为 2.8。

因此,相机似乎正在报告给定当前焦点设置的镜头的有效最大光圈。这是有道理的,因为可变最大光圈变焦镜头很流行。如果您使用具有可变最大光圈的变焦镜头(例如 Nikkor 18-200 f3.5 / f5.6),则给定变焦设置和对焦设置下的有效最大光圈由相机计算并嵌入到EXIF 数据。该值由 Preview 显示并可能由 ImageIO 框架更正。

请参阅T-Stops

Try the ImageIO framework from Quartz 2D.

Specifically CGImageSourceCopyProperties with CGImageProperties set to kCGImagePropertyExifDictionary

To get 2.8 vs 3 for the max aperture, you may need to set kCGImageSourceShouldAllowFloat appropriately.

It's not Cocoa, but easy to use and xfer to Cocoa.

Edit

The part above about setting kCGImageSourceShouldAllowFloat is incorrect...

I just put an f2.8 60mm Micro Nikkor prime lens on a Nikon D7000 to check this. I took one image of a very close object (3 inches away), another at mid focus (6 feet) and a third at distant focus.

The close focus image EXIF reported "Max Aperture" value of 3.2 in Preview. Photoshop allows the raw EXIF data embedded in the file to be seen. If I open the close object image in Photoshop, the embedded EXIF is shown as 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). Only the distant focus reported "Max Aperture" value of 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. This value is corrected shown by Preview and assumably by the ImageIO framework.

See T-Stops

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文