照片的元数据并转换为NSData

时间:2014-06-20 20:37:51

标签: ios objective-c nsdate alassetslibrary

因此,我的应用可让用户从iOS设备的照片库中选择一张照片。选中后,我会检查GPS元​​数据:

NSString *mediatType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediatType isEqualToString:(NSString *)kUTTypeImage]) {
    NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL];

    if (url) {
        ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init];
        [assetsLibrary assetForURL:url
                       resultBlock:^(ALAsset *myasset) {
                           CLLocation *photoLocation = [myasset valueForProperty:ALAssetPropertyLocation];
                           DLog(@"photoLocation: %@", photoLocation);
                       }
                      failureBlock:^(NSError *error) {
                          DLog(@"can't get image: %@", [error localizedDescription]);
                      }];
    }
}

我现在有点迷失了,我需要将Photo转换为NSData用于本地存储,然后转换为Base64以上传到我们的服务器。

如果我使用:

NSData *photoData = UIImageJPEGRepresentation([info objectForKey:UIImagePickerControllerOriginalImage], 1);

将元数据包装到图像文件/数据中,这样当我上传时,服务器将能够读取图像文件中的元数据吗?

0 个答案:

没有答案