IOS 8 UIImage Metadata

This is my first question

I have a little problem: when I read the UIImage metadata on iOS 7, I use this code and it works fine

 #pragma mark - Image Picker Controller delegate methods

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

    UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage]; 
    [self metaDataFromAssetLibrary:info];       
    [picker dismissViewControllerAnimated:YES completion:NULL];

}

      

From the imagePickerController I select the image and call the metaDataFromAssetLibrary method

- (void) metaDataFromAssetLibrary:(NSDictionary*)info
{

    NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];

    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    [library assetForURL:assetURL
             resultBlock:^(ALAsset *asset)  {

                        NSMutableDictionary *imageMetadata = nil;
                 NSDictionary *metadata = asset.defaultRepresentation.metadata;
                imageMetadata = [[NSMutableDictionary alloc] initWithDictionary:metadata];
                 NSLog (@"imageMetaData from AssetLibrary %@",imageMetadata);

             }
            failureBlock:^(NSError *error) {
                NSLog (@"error %@",error);
            }];

}

      

on Xcode5 and iOS7 console return something like this

imageMetaData from AssetLibrary {
    ColorModel = RGB;
    DPIHeight = 72;
    DPIWidth = 72;
    Depth = 8;
    Orientation = 1;
    PixelHeight = 2448;
    PixelWidth = 3264;
    "{Exif}" =     {
        ApertureValue = "2.52606882168926";
        BrightnessValue = "2.211389961389961";
        ColorSpace = 1;
        ComponentsConfiguration =         (
            1,
            2,
            3,
            0
        );
        DateTimeDigitized = "2014:06:05 08:54:09";
        DateTimeOriginal = "2014:06:05 08:54:09";
        ExifVersion =         (
            2,
            2,
            1
        );
        ExposureMode = 0;
        ExposureProgram = 2;
        ExposureTime = "0.05";
        FNumber = "2.4";
        Flash = 24;
        FlashPixVersion =         (
            1,
            0
        );
        FocalLenIn35mmFilm = 35;
        FocalLength = "4.28";
        ISOSpeedRatings =         (
            125
        );
        LensMake = Apple;
        LensModel = "iPhone 4S back camera 4.28mm f/2.4";
        LensSpecification =         (
            "4.28",
            "4.28",
            "2.4",
            "2.4"
        );
        MeteringMode = 3;
        PixelXDimension = 3264;
        PixelYDimension = 2448;
        SceneCaptureType = 0;
        SceneType = 1;
        SensingMethod = 2;
        ShutterSpeedValue = "4.321928460342146";
        SubjectArea =         (
            1643,
            1079,
            610,
            612
        );
        SubsecTimeDigitized = 347;
        SubsecTimeOriginal = 347;
        WhiteBalance = 0;
    };
    "{GPS}" =     {
        Altitude = 26;
        AltitudeRef = 1;
        DateStamp = "2014:06:05";
        DestBearing = "177.086387434555";
        DestBearingRef = M;
        ImgDirection = "357.0864197530864";
        ImgDirectionRef = M;
        Latitude = "43.80268";
        LatitudeRef = N;
        Longitude = "11.0635195";
        LongitudeRef = E;
        Speed = 0;
        SpeedRef = K;
        TimeStamp = "06:54:08";
    };
    "{MakerApple}" =     {
        1 = 0;
        3 =         {
            epoch = 0;
            flags = 1;
            timescale = 1000000000;
            value = 27688938393500;
        };
        4 = 1;
        5 = 186;
        6 = 195;
        7 = 1;
        8 =         (
            "-0.6805536",
            "0.02519802",
            "-0.755379"
        );
    };
    "{TIFF}" =     {
        DateTime = "2014:06:05 08:54:09";
        Make = Apple;
        Model = "iPhone 4S";
        Orientation = 1;
        ResolutionUnit = 2;
        Software = "8.0";
        XResolution = 72;
        YResolution = 72;
    };
}

      

But on Xcode6 and iOS 8 console only these are returned

imageMetaData from AssetLibrary {
    ColorModel = RGB;
    DPIHeight = 72;
    DPIWidth = 72;
    Depth = 8;
    Orientation = 1;
    PixelHeight = 768;
    PixelWidth = 1020;
    "{Exif}" =     {
        ColorSpace = 1;
        ComponentsConfiguration =         (
            1,
            2,
            3,
            0
        );
        ExifVersion =         (
            2,
            2,
            1
        );
        FlashPixVersion =         (
            1,
            0
        );
        PixelXDimension = 1020;
        PixelYDimension = 768;
        SceneCaptureType = 0;
    };
    "{TIFF}" =     {
        Orientation = 1;
        ResolutionUnit = 2;
        XResolution = 72;
        YResolution = 72;
    };
}

      

does anyone know this problem?

any solution or suggestion?

Thank you very much

PS: Excuse me for my terrible English; -)

+2


source to share


1 answer


After upgrading to Xcode6, you should get the image in the completion block rejectController, or a more complex method: get the image from the asset.

Please try the following code:



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

    [picker dismissViewControllerAnimated:YES completion::^{
        UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage]; 
        [self metaDataFromAssetLibrary:info];       
    }];

      

Also you can refer to john.k.doe's answer in didFinishPickingMediaWithInfo returns zero

+2


source







All Articles