title: Mac OS X 10.6 APIs report incorrect EXIF data for aperture
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>(Knowing what lens I was using, ExifTool is correct when it reports MaxApertureValue as 2.8.)</p>
  
  <p>Details: Xcode 4.02, OS X 10.6.7, 10.6 SDK</p>
  
  <p>Anyone else notice this anomaly?</p>
  
  <pre><code>#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
  
  */
  </code></pre>
  
  <p>Update: It's not me. Here's the EXIF data as reported by Apple's Preview app:</p>
  
  <p><img src="https://i.stack.imgur.com/qoYh1.png" alt="EXIF data from Preview"></p>