Friday, January 21, 2011

What is Inside UIImagePickerControllerMediaMetadata

Been debugging UIImagePickerController too many times, so it's time for some tips. The most easy way to see what's in there somewhere. Also including a sample output.

Code:
- (void)imagePickerController:(UIImagePickerController *)picker
   didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [picker dismissModalViewControllerAnimated:YES];
    [picker release];

    // DEBUG
    NSLog(@"%@", [info description]);
}
Sample data for portrait image taken with iPhone 3GS running iOS 4.2.1 (as you can see in "TIFF" data). This data comes from NSLog() in code sample above.
2011-01-21 06:20:38.713 DemoApp[984:307] {
    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;
        };
    };
    UIImagePickerControllerMediaType = "public.image";
    UIImagePickerControllerOriginalImage = "<UIImage: 0x1881c0>";
}
 Sample data for old image:
2011-01-21 06:59:44.386 DemoApp[1044:307] {
    UIImagePickerControllerMediaType = "public.image";
    UIImagePickerControllerOriginalImage = "<UIImage: 0x195830>";
    UIImagePickerControllerReferenceURL = "assets-library://asset/asset.JPG?id=1000000188&ext=JPG";
}

3 comments:

  1. Just to clarify that the sample data is debug console output from NSLog() command. Yep, got email asking about this :) Nope, I am not able to reply to all emails, bank thinks I should pay back the loan :(

    ReplyDelete
  2. Hi Jouni

    I am getting incomplete metadata on iPhone 4. See below. I don't see any flags to set for specific metadata Any Idea?

    Thanks

    Jean-Pierre

    UIImagePickerControllerMediaMetadata = {
    DPIHeight = 72;
    DPIWidth = 72;
    Orientation = 6;
    "{Exif}" = {
    ColorSpace = 1;
    DateTimeDigitized = "2011:04:22 12:42:16";
    DateTimeOriginal = "2011:04:22 12:42:16";
    PixelXDimension = 1936;
    PixelYDimension = 2592;
    };
    "{TIFF}" = {
    DateTime = "2011:04:22 12:42:16";
    Make = Apple;
    Model = "iPhone 4";
    Software = "4.3.2";
    XResolution = 72;
    YResolution = 72;
    };
    };

    ReplyDelete
  3. Sorry, don't know any way to get "additional" metadata. As far as I know now, you get "all" by default. Guess difference is due iOS version and hardware?

    ReplyDelete