iOS 关于图片地理位置隐私信息的分析和读取

今天突然想到微信朋友圈发照片,涉及个人隐私的地理位置是否外泄。由于iphone拍照的照片都会带有地理位置等信息。我们先来实现怎么读取里面的安全信息。然后再来分析

#import "ViewController.h"
#import <ImageIO/ImageIO.h>
#import <AssetsLibrary/AssetsLibrary.h>
@interface ViewController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    
    //创建一个UIImagePickerController对象
    UIImagePickerController *ctrl = [[UIImagePickerController alloc] init];
    //设置类型
    ctrl.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    //设置代理
    ctrl.delegate = self;
    
    //显示
    [self presentViewController:ctrl animated:YES completion:nil];
    

    
    
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

    
    
    if(picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary){
        //UIImage *image= [info objectForKey:UIImagePickerControllerOriginalImage];
        
        NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
        
        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library assetForURL:assetURL
                 resultBlock:^(ALAsset *asset) {
                     NSDictionary* imageMetadata = [[NSMutableDictionary alloc] initWithDictionary:asset.defaultRepresentation.metadata];

                     
                     NSDictionary *GPS = [imageMetadata objectForKey:(NSString *)kCGImagePropertyGPSDictionary];
                     NSLog(@"--------%@",GPS);//地理位置信息
                     NSLog(@"%@",imageMetadata); 
                    
                 } 
                failureBlock:^(NSError *error) { 
                }]; 
    }
    
    
}




经过我的调查:

首先朋友假设用微信。原图形式发给你的照片。是带有地理位置信息的。你先保存到相冊,然后利用上面的代码试试看。

假设不是原图形式的。那么这些安全信息都会被抹去。

所以一般发到朋友圈,微博这些社交平台上。

照片不是原图形式,地理位置这些安全信息是看不到的。能够放心使用。

我不知道能不能通过某种方法读取的不是原图形式的照片安全信息。假设会的朋友请告诉我噢。。。

原文地址:https://www.cnblogs.com/jzssuanfa/p/6848068.html