Image 在手机里 如果是手机拍的那么能使用ALAssetsLibrary获取一系列 图片的信息 颜色、GPS、尺寸、创建日期等

使用ALAssetsLibrary导入框架AssetsLibrary.framework  引入头文件

#import <AssetsLibrary/AssetsLibrary.h>

以手机相册为例代码如下:(获取gps里面时间戳为例)

#pragma -mark UIImagePickerController delegate
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
chosenImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
// 指定回调方法 [picker dismissViewControllerAnimated:YES completion:NULL];
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 *GPSDict=[imageMetadata objectForKey:@"{GPS}"]; NSLog(@"时间:DateStamp:%@",[GPSDict objectForKey: @"DateStamp"]); } failureBlock:^(NSError *error) { }];
}

当手机上同步的照片 和手机自身截图 我却发现字典里面没有创建日期或者GPS的相关信息了

我找到一个方法只要是手机的图片,就可以获取图片创建日期的方法。其他相关的信息以后用到再深究。

NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:assetURL
resultBlock:^(ALAsset *asset) {
NSDate* date = [asset valueForProperty:ALAssetPropertyDate];
NSLog(@"date:%@",date);
}
failureBlock:^(NSError *error) {
}];

其二,当图片以文件形式在沙盒里面的话,主要就是根据文件路径来解决

最新文章

  1. C#中5步完成word文档打印的方法
  2. Linux入侵检测常用命令
  3. easyui datagrid 没数据时显示滚动条的解决方法
  4. 小白详细讲解快速幂--杭电oj2035-A^B
  5. 《慕客网:IOS基础入门之Foundation框架初体验》学习笔记 &lt;五&gt; NSDicionary + NSMutableDictionary
  6. python 反模式
  7. Java RGB数组图像合成 ImageCombining (整理)
  8. Android(java)学习笔记229:服务(service)之绑定服务调用服务里面的方法 (采用接口隐藏代码内部实现)
  9. Aptana Studio 快捷键
  10. Android SDK Manager 无法更新SDK
  11. C++程序设计实践指导1.12数组中数据线性变换改写要求实现
  12. DataNode连接错误Retrying connect to server
  13. FWT模板
  14. 剑指offer——python【第36题】两个链表的第一个公共结点
  15. 剑指Offer 2. 替换空格 (字符串)
  16. python之路——10
  17. Ubuntu 18.04 安装中文输入法ibus
  18. VIM编辑器和VI编辑器的区别
  19. HTTP 1.0 Status Code Definitions
  20. idea 安装mybatis plugin (mybatis插件)

热门文章

  1. struts2获取ServletContext对象
  2. 我如何添加一个空目录到Git仓库?
  3. robotframework使用之RIDE的底部的日志没显示怎么办?
  4. TextView上的文字逐渐变淡直到消失
  5. Cloudera Manager 和 CDH 4 终极安装
  6. Theme.AppCompat.Light.DarkActionBar ActionBarActivity
  7. apache common包 CollectionUtils 使用 详解
  8. UML类图简明教程
  9. jQuery--基础(实例)
  10. SpringMvc自动代理