【问题标题】:iPhone iOS how to extract photo metadata and geotagging info from a camera roll image? [duplicate]iPhone iOS 如何从相机胶卷图像中提取照片元数据和地理标记信息? [复制]
【发布时间】:2012-04-24 09:11:36
【问题描述】:

可能重复:
How Do I Get The Correct Latitude and Longitude From An Uploaded iPhone Photo?

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

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

【问题讨论】:

    标签: iphone objective-c ios photo geotagging


    【解决方案1】:

    是的,有可能。

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

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

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

    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 检查它,因为有些照片可能缺少此数据。

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

    【讨论】:

      猜你喜欢
      • 2011-11-26
      • 1970-01-01
      • 2014-04-21
      • 1970-01-01
      • 2013-06-19
      • 1970-01-01
      • 1970-01-01
      • 2014-11-02
      • 1970-01-01
      相关资源
      最近更新 更多