iOS 关于图片地理位置隐私信息的分析和读取
2016-06-17 08:14
477 查看
今天突然想到微信朋友圈发照片,涉及个人隐私的地理位置是否外泄。因为iphone拍照的照片都会带有地理位置等信息,我们先来实现怎么读取里面的安全信息,然后再来分析
[objc] view plain copy
#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) {
}];
}
}
[objc] view plain copy
#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图片压缩上传
- iOS图片上传1
- iOS应用支持IPV6,就那点事儿
- iOS 实现第三方登录(图文)
- iOS_PDf
- iOS模糊效果的实现
- iOS视图学习——TableView
- iOS高级开发路线
- [一句秒懂]ios圆形图片显示
- iOS开发探索-图片压缩处理
- iOS关于图片点到像素转换之杂谈
- AVPlayer 实现视频播放器的开发
- IOS开发基础知识--碎片41
- iOS Documents、Library跟tmp的作用
- android和iOS中打包html5
- 判断是否textField保留两位小数(或者多位小数)
- iOS: 删除真机测试的Provisioning Profile后,在Code Singing中出现entitlements.plist文件无效,解决办法如下:
- iOS开发教程之Objc Runtime笔记
- ios宏定义的参数 编译可以通过,但是提示有错误
- iOS自动释放池_原理_如何工作