【发布时间】:2016-07-10 10:09:32
【问题描述】:
我可以将Photo Sphere XMP Metadata 添加到 equirectangular 照片。 我将带有 XMP 元数据的照片上传到 Google Photos,Google Photos 能够被识别为球形照片。 然后,我尝试将带有 XMP 元数据的照片保存到相机胶卷。 我将照片从相机胶卷分享到 Google 相册,但 Google 相册不知道它是球形照片。 我试图下载照片并分析它,发现 XMP 元数据都不见了。 当照片保存到相机胶卷时,iOS 似乎会编辑元数据。 有什么方法可以在将照片保存到相机胶卷的同时保留照片的 XMP 元数据?
// raw jpg data to NSData
NSString *img = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"equirectangular_orig.jpg"];
NSData* imgData = [[NSFileManager defaultManager] contentsAtPath:img];
NSMutableData *newImgData = [NSMutableData dataWithData:imgData];
// writing XMP metadata to newImgData
// ...
// ...
// saving the newImgData to new jpg file
NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"equirectangular_xmp.jpg"];
NSURL *url = [NSURL fileURLWithPath:path];
[[NSFileManager defaultManager] removeItemAtPath:[url absoluteString] error:nil];
[newImgData writeToURL:url atomically:YES];
// saving the new jpg file to camera roll
UIImage *newImg = [UIImage imageWithData:newImgData];
UIImageWriteToSavedPhotosAlbum(newImg, self, nil, nil);
【问题讨论】:
-
其实我发现一旦我们将图片从NSData存储到UIImage,UIImage就会破坏原始数据。
标签: ios exif alassetslibrary xmp camera-roll