如何从ALAsset获取exif信息?

发布于 2024-12-20 19:26:17 字数 55 浏览 1 评论 0 原文

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雪花飘飘的天空 2024-12-27 19:26:17
[[asset defaultRepresentation] metadata];

返回给定资产表示的元数据字典的字典。查看此字典中是否有您感兴趣的数据。我不确定,但我认为该字典(和子字典)中的键与 CGImageProperties 参考

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

好久不见√ 2024-12-27 19:26:17

这是一个完整的答案......全部集中在一个

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

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 ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文