IOS 如何获取与修改图片的EXIF信息
2016-10-25 14:46
676 查看
简介:Exif是一种图像文件格式,它的数据存储与JPEG格式是完全相同的。实际上Exif格式就是在JPEG格式头部插入了数码照片的信息,包括拍摄时的光圈、快门、白平衡、ISO、焦距、日期时间等各种和拍摄条件以及相机品牌、型号、色彩编码、拍摄时录制的声音以及GPS全球定位系统数据、缩略图等。你可以利用任何可以查看JPEG文件的看图软件浏览Exif格式的照片,但并不是所有的图形程序都能处理Exif信息。
获取EXIF信息代码如下:
修复EXIF信息代码如下:
获取EXIF信息代码如下:
- (NSMutableDictionary *)getExifInfoWithImageData:(NSData *)imageData{ CGImageSourceRef cImageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); NSDictionary *dict = (NSDictionary *)CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(cImageSource, 0, NULL)); NSMutableDictionary *dictInfo = [NSMutableDictionary dictionaryWithDictionary:dict]; return dictInfo; }
修复EXIF信息代码如下:
/* * 仅支持JPEG格式 */ -(NSMutableData *)setExifInfoWithImageData:(NSData *)imageNSData{ CGImageSourceRef imgSource = CGImageSourceCreateWithData((__bridge_retained CFDataRef)imageNSData, NULL); NSDictionary *metadata = (__bridge NSDictionary *)CGImageSourceCopyPropertiesAtIndex(imgSource, 0, NULL); NSMutableDictionary *metadataAsMutable = [metadata mutableCopy]; NSMutableDictionary *EXIFDictionary = [[metadataAsMutable objectForKey:(NSString *)kCGImagePropertyExifDictionary] mutableCopy]; if (EXIFDictionary==nil) { EXIFDictionary = [[NSMutableDictionary alloc] init]; } [EXIFDictionary setObject:@"mengxiaoxiong" forKey:(NSString *)kCGImagePropertyExifUserComment]; [metadataAsMutable setObject:EXIFDictionary forKey:(NSString *)kCGImagePropertyExifDictionary]; NSLog(@"Info: %@",metadataAsMutable); CFStringRef UTI = CGImageSourceGetType(imgSource); NSMutableData *newImageData = [NSMutableData data]; CGImageDestinationRef destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)newImageData, UTI, 1, NULL); if(!destination) NSLog(@"***创建 失败***"); CGImageDestinationAddImageFromSource(destination, imgSource, 0, (__bridge CFDictionaryRef) metadataAsMutable); BOOL success = NO; success = CGImageDestinationFinalize(destination); if(!success) NSLog(@"***保存 失败***"); return newImageData; }
相关文章推荐
- IOS: 使用imageIO获取和修改图片的exif信息
- 使用imageIO获取和修改图片的exif信息
- ios获取图片exif信息
- 使用imageIO获取和修改图片的exif信息
- 使用imageIO获取和修改图片的exif信息
- Android 图片Exif信息相关的获取与修改
- 获取图片的EXIF信息如此困难?
- IOS_将GPS等EXIF信息写进任意JPEG图片(不依托UIImagePickerController)
- ios获取本地图片以及图片信息
- 以最省内存的方式把大图片加载到内存及获取Exif信息和获取屏幕高度和宽度的新方法
- 当将图片文件放在与项目同级的目录下时该如何获取图片信息
- 给图片文件写入exif信息(ios)
- C# 获取图片的EXIF 信息 .
- 越狱的 ios 如何 获取 读取 提取 手机上的 短信 通话记录 联系人 等信息
- 以最省内存的方式把大图片加载到内存及获取Exif信息和获取屏幕高度和宽度的新方法
- C#图片处理惩罚之: 获取数码相片的EXIF信息
- [iOS学习笔记] 如何在Xcode 4中修改代码的Copyright信息
- 获取图片GPS等exif信息的功能模块
- java获取文件exif信息-添加图片文字水印
- 如何将地图SDK中获取到的经纬度信息写入到exif中