本文介绍了Mac OS X 10.6 API报告光圈的EXIF数据不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我使用两个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



任何人都注意到这个异常?

  #importExifTestAppDelegate.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版本号:8.51
...
F数量:8.0
...
光圈值:8.0
...
最大光圈值:2.8

* /

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



解决方案

尝试从Quartz 2D ImageIO框架。



特别与设置为



获得 2.8 vs 3 对于最大光圈,您可能需要设置 kCGImageSourceShouldAllowFloat 。 / p>

这不是可可,而是容易使用和xfer到Cocoa。



编辑



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



我只是在尼康D7000上放了一个f2.8 60mm Micro Nikkor镜头镜头来检查。我拍摄了一个非常近的物体(3英寸远)的图像,另一个在中焦点(6英尺),第三个在远焦点。



近焦图像EXIF在预览中报告最大光圈值为3.2。 Photoshop允许嵌入在文件中的原始EXIF数据被看到。如果我在Photoshop中打开关闭对象图像,嵌入的EXIF显示为 exif:MaxAperatureValue:32/10



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



因此,根据焦点的当前设置,相机会报告镜头的有效最大光圈。这是有道理的,因为可变最大光圈变焦镜头的普及。如果将变焦镜头置于具有可变最大光圈(例如Nikkor 18-200 f3.5 / f5.6)的位置,则给定变焦设置和对焦设置下的有效最大光圈由相机计算并嵌入EXIF数据。此值由校正显示,并由ImageIO框架假定。



请参阅


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:

解决方案

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

这篇关于Mac OS X 10.6 API报告光圈的EXIF数据不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 09:26