iPhone iOS如何从相机胶卷图像中提取照片元数据和地理标记信息? [英] iPhone iOS how to extract photo metadata and geotagging info from a camera roll image?

查看:383
本文介绍了iPhone iOS如何从相机胶卷图像中提取照片元数据和地理标记信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何从上传的iPhone照片获得正确的纬度和经度?

我正在制作一个照片应用程序,想知道我使用地理标记照片有哪些选择。 我想显示拍摄照片的位置(类似于照片应用)。这可能吗?

I'm making a photo app and would like to know what are my options for working with geotagged photos. I would like to display where a photo has been taken (similar to photos app). Is this possible?

此外,我需要知道拍摄照片的时间。我可以捕获我自己拍摄的照片的这些信息,但相机胶卷图像呢?

Additionally, I need to know when the picture has been taken. I can capture this info for the pictures that I take myself, but what about the camera roll images?

推荐答案

是的,有可能。

你必须使用 ALAssetsLibrary 可访问您的相机胶卷。然后你只需枚举你的照片并询问位置。

You have to use ALAssetsLibrary to access your camera roll. Then you just enumerate through your photos and asks for location.

assetsLibrary = [[ALAssetsLibrary alloc] init];
groups = [NSMutableArray array];

[assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos  usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{
    if (group == nil)
    {
        return;
    }

    [groups addObject:group];

} failureBlock:^(NSError *error)
{
    // Possibly, Location Services are disabled for your application or system-wide. You should notify user to turn Location Services on. With Location Services disabled you can't access media library for security reasons.

}];

这将枚举您的资产组。接下来,您选择一个组并枚举其资产。

This will enumerate your assets groups. Next, you pick up a group and enumerate its assets.

ALAssetGroup *group = [groups objectAtIndex:0];
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
 {
     if (result == nil)
     {
         return;
     }

     // Trying to retreive location data from image
     CLLocation *loc = [result valueForProperty:ALAssetPropertyLocation];    
 }];

现在你的 loc 变量包含的位置照片拍摄地点。你应该在使用前检查 ALErrorInvalidProperty ,因为有些照片可能缺少这些数据。

Now your loc variable contains location of the place where the photo was taken. You should check it against ALErrorInvalidProperty before use, since some photos might lack this data.

你可以指定 ALAssetPropertyDate 获取照片创建的日期和时间。

You can specify ALAssetPropertyDate to obtain the date and time of photo creation.

这篇关于iPhone iOS如何从相机胶卷图像中提取照片元数据和地理标记信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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