Dejan
Dejan

Reputation: 139

How to grab image EXIF metadata (ISO, f-stop, exposure, etc.) from a photo in iOS?

In earlier versions of iOS I was able get EXIF dictionary with PLCameraController via

-(void)cameraController:(id)sender
   tookPicture:(UIImage*)picture
   withPreview:(UIImage*)preview
      jpegData:(NSData*)rawData
  imageProperties:(id)imageProperties

This no longer works in iOS 4+.

How can I get EXIF metadata in iOS such as ISO number, F-number etc?

Upvotes: 4

Views: 2187

Answers (1)

memmons
memmons

Reputation: 40502

As of iOS 4.1, you can get the image metadata for a photo that was taken using the UIImagePickerControllerMediaMetadata key.

- (void)imagePickerController:(UIImagePickerController *)picker
              didFinishPickingMediaWithInfo:(NSDictionary *)info 
{

    NSDictionary *metadataDictionary = 
         (NSDictionary *)[info valueForKey:UIImagePickerControllerMediaMetadata];
    // do something with the metadata
}

If you log the ouput of [info description] you can see all the metadata that is available --

UIImagePickerControllerMediaMetadata =     {
    DPIHeight = 72;
    DPIWidth = 72;
    Orientation = 6;
    "{Exif}" =         {
        ApertureValue = "2.970853654340484";
        ColorSpace = 1;
        DateTimeDigitized = "2011:01:21 06:20:36";
        DateTimeOriginal = "2011:01:21 06:20:36";
        ExposureMode = 0;
        ExposureProgram = 2;
        ExposureTime = "0.01666666666666667";
        FNumber = "2.8";
        Flash = 32;
        FocalLength = "3.85";
        ISOSpeedRatings =             (
            100
        );
        MeteringMode = 1;
        PixelXDimension = 2048;
        PixelYDimension = 1536;
        SceneType = 1;
        SensingMethod = 2;
        Sharpness = 1;
        ShutterSpeedValue = "5.906892602837797";
        SubjectArea =             (
            1023,
            767,
            614,
            614
        );
        WhiteBalance = 0;
    };
    "{TIFF}" =         {
        DateTime = "2011:01:21 06:20:36";
        Make = Apple;
        Model = "iPhone 3GS";
        Software = "4.2.1";
        XResolution = 72;
        YResolution = 72;
    };
};

Upvotes: 3

Related Questions