[英]Mac OS X 10.6 APIs report incorrect EXIF data for aperture
我正在使用两个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数据:
尝试使用Quartz 2D的ImageIO框架。
特别是将CGImageProperties设置为kCGImagePropertyExifDictionary的CGImageSourceCopyProperties
要使最大光圈达到2.8
vs 3
,您可能需要适当地设置kCGImageSourceShouldAllowFloat
。
它不是可可,但易于使用,可扩展到可可。
编辑
上面有关设置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数据。 此值已由Preview显示,并可能由ImageIO框架显示。
见止动
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.