How to get exif information from ALAsset?

血红的双手。 提交于 2020-01-05 23:17:14

问题


I need to get exif information from selected asset and to display part of it on the screen.


回答1:


[[asset defaultRepresentation] metadata];

returns a dictionary of dictionaries of metadata for the given asset representation. Check out this dictionary for the data you're interested in. I am not sure but I think the keys in that dictionary (and subdictionaries) are the same as the ones listed under CGImageProperties Reference.




回答2:


This is a complete answer ... all in one spot

NSDictionary *nsd = [[asset3 defaultRepresentation] metadata];
    NSString *widthStr = [nsd objectForKey: @"PixelWidth"];
    NSString *heightStr = [nsd objectForKey: @"PixelHeight"];

    NSLog(@"nsd: %@ ... widthStr: %@ ... heightStr: %@ ...", nsd, widthStr, heightStr);

output:

nsd: {
    ColorModel = RGB;
    DPIHeight = 72;
    DPIWidth = 72;
    Depth = 8;
    Orientation = 1;
    PixelHeight = 1136;
    PixelWidth = 642;
    "{Exif}" =     {
        ColorSpace = 1;
        ComponentsConfiguration =         (
            1,
            2,
            3,
            0
        );
        ExifVersion =         (
            2,
            2,
            1
        );
        FlashPixVersion =         (
            1,
            0
        );
        PixelXDimension = 642;
        PixelYDimension = 1136;
        SceneCaptureType = 0;
    };
    "{TIFF}" =     {
        Orientation = 1;
        ResolutionUnit = 2;
        XResolution = 72;
        YResolution = 72;
    };
} ... widthStr: 642 ... heightStr: 1136 ...


来源:https://stackoverflow.com/questions/8475057/how-to-get-exif-information-from-alasset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!