如何从ALAsset获取exif信息?

时间:2011-12-12 13:26:50

标签: objective-c uiimage exif alassetslibrary assets

我需要从所选资产中获取 exif 信息,并在屏幕上显示部分内容。

2 个答案:

答案 0 :(得分:10)

[[asset defaultRepresentation] metadata];

返回给定资产表示的元数据字典字典。查看这本词典,了解您感兴趣的数据。我不确定,但我认为该词典(和子词典)中的键与CGImageProperties Reference下列出的键相同。

答案 1 :(得分:0)

这是一个完整的答案......全部在一个地方

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

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

输出:

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 ...