我有一点问题,我遵循这个主题 Problem setting exif data for an image
对于我的图像上保存exif,我保存一条评论,功能工作,我将图像保存在我的文档根目录
// Documents
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"];
[dest_data writeToFile:jpgPath atomically:YES];
// Create file manager
NSError *error;
NSFileManager *fileMgr = [NSFileManager defaultManager];
// Point to Document directory
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
// Write out the contents of home directory to console
NSLog(@"Documents directory: %@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);
但是当我从文档根加载图像时没有exif,对于我使用的加载图像
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"];
UIImage *loadedImage = [UIImage imageWithContentsOfFile:jpgPath];
NSData *jpeg = UIImageJPEGRepresentation(loadedImage,1.0);
CGImageSourceRef source ;
source = CGImageSourceCreateWithData((CFDataRef)jpeg, NULL);
NSDictionary *metadataNew = (NSDictionary *) CGImageSourceCopyPropertiesAtIndex(source,0,NULL);
NSLog(@"%@",metadataNew);
我确定exif已保存,因为如果我从模拟器根打开图像,则图像具有exif数据。
此外,如果我尝试在我的服务器上传图像,则它没有exif数据。 问题出在哪儿?
答案 0 :(得分:2)
直接将其读入NSData,例如:
NSData *jpeg=[[NSData alloc] initWithContentsOfFile:jpgPath];
这将包含EXIF数据。