iOS 關於圖片地理位置隱私信息的分析和讀取
阿新 • • 發佈:2017-05-13
img control res 位置信息 log mutable hone tro art
今天突然想到微信朋友圈發照片,涉及個人隱私的地理位置是否外泄。由於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) { }]; } }
經過我的調查:
首先朋友假設用微信。原圖形式發給你的照片。是帶有地理位置信息的。你先保存到相冊,然後利用上面的代碼試試看。
假設不是原圖形式的。那麽這些安全信息都會被抹去。
所以一般發到朋友圈,微博這些社交平臺上。
照片不是原圖形式,地理位置這些安全信息是看不到的。能夠放心使用。
我不知道能不能通過某種方法讀取的不是原圖形式的照片安全信息。假設會的朋友請告訴我噢。。。
iOS 關於圖片地理位置隱私信息的分析和讀取