zoukankan      html  css  js  c++  java
  • iOS 关于图片地理位置隐私信息的分析和读取

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

     

    [objc] view plain copy
     
    1. #import "ViewController.h"  
    2. #import <ImageIO/ImageIO.h>  
    3. #import <AssetsLibrary/AssetsLibrary.h>  
    4. @interface ViewController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>  
    5.   
    6. @end  
    7.   
    8. @implementation ViewController  
    9.   
    10. - (void)viewDidLoad {  
    11.     [super viewDidLoad];  
    12.      
    13.       
    14.     //创建一个UIImagePickerController对象  
    15.     UIImagePickerController *ctrl = [[UIImagePickerController alloc] init];  
    16.     //设置类型  
    17.     ctrl.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;  
    18.     //设置代理  
    19.     ctrl.delegate = self;  
    20.       
    21.     //显示  
    22.     [self presentViewController:ctrl animated:YES completion:nil];  
    23.       
    24.   
    25.       
    26.       
    27. }  
    28.   
    29. -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info  
    30. {  
    31.   
    32.       
    33.       
    34.     if(picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary){  
    35.         //UIImage *image= [info objectForKey:UIImagePickerControllerOriginalImage];  
    36.           
    37.         NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];  
    38.           
    39.         ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];  
    40.         [library assetForURL:assetURL  
    41.                  resultBlock:^(ALAsset *asset) {  
    42.                      NSDictionary* imageMetadata = [[NSMutableDictionary alloc] initWithDictionary:asset.defaultRepresentation.metadata];  
    43.   
    44.                        
    45.                      NSDictionary *GPS = [imageMetadata objectForKey:(NSString *)kCGImagePropertyGPSDictionary];  
    46.                      NSLog(@"--------%@",GPS);//地理位置信息  
    47.                      NSLog(@"%@",imageMetadata);   
    48.                       
    49.                  }   
    50.                 failureBlock:^(NSError *error) {   
    51.                 }];   
    52.     }  
    53.       
    54.       
    55. }  


     

  • 相关阅读:
    获取具有指定扩展数据的所有实体的Id,并存入Id数组中
    FastDFS单机版安装教程
    Git简要开发流程
    Delay延迟队列
    HTTP调用接口方法
    Tomcat为什么要使用Facde模式对Request对象进行包装?
    SpringBoot注解
    <th:>标签使用
    Git命令速查表
    IDEA中对Git的常规操作(合并,提交,新建分支,更新)
  • 原文地址:https://www.cnblogs.com/LiLihongqiang/p/5592713.html
Copyright © 2011-2022 走看看