exif 已保存但未加载 - iphone
我有一个小问题,我按照这个线程 为图像设置 exif 数据时出现问题
以将 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 已保存,因为如果我打开图片来自模拟器 root 图像具有 exif 数据。
另外,如果我尝试将图像上传到我的服务器上,它没有 exif 数据。 问题出在哪里?
I have a little problem, I follow this thread
Problem setting exif data for an image
for save exif on my image, I save a comment, the funciont work, I save the image on my document root
// 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]);
but when I load the image from document root there is no exif, for load image I use
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);
I'm sure that the exif was saved because if I open the image from simulator root the image has the exif data.
Also if I try to upload the image on my server it hasn't exif data.
where is the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
直接将其读入 NSData,例如:
这将包含 EXIF 数据。
Read it into the NSData directly, eg:
This will contain the EXIF data.