iOS 8 UIImage元数据 [英] iOS 8 UIImage Metadata

查看:140
本文介绍了iOS 8 UIImage元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个问题

我有一个小问题:当我在iOS 7上阅读UIImage元数据时
我使用此代码并且它效果很好

I've a a "little" problem: when i read UIImage metadata on iOS 7 I use this code and it works great

 #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];

}

来自imagePickerController我选择图像并调用metaDataFromAssetLibrary方法

From imagePickerController i choose the image and call 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);
            }];

}

在Xcode5和iOS7控制台上返回类似这样的内容

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;
    };
}

但是在Xcode6和iOS 8控制台上只返回此

But on Xcode6 and iOS 8 console return only this

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;
    };
}

有人知道这个问题吗?

任何解决方案或建议?

非常感谢

PS:请原谅我的可怕英语; - )

P.S.: excuse me for my terrible english ;-)

推荐答案

升级到Xcode6后,你必须在dismissViewController的完成块或更复杂的方法中获取图像:从资产中获取图像。

After upgrade to Xcode6, you have to get the image in dismissViewController's completion block, or more complex method: get the image from asset.

请尝试以下代码:

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

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

您还可以在
didFinishPickingMediaWithInfo返回零照片

这篇关于iOS 8 UIImage元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆