将表示图像的 NSMutableData 保存到 iPhone 照片库

发布于 2024-12-03 01:01:56 字数 1021 浏览 0 评论 0原文

我有一个包含 JPEG 的 NSMutableData,我想将其保存在设备库中。

我可以将其转换为 UIImage,但随后它会丢失 EXIF 数据,因此应避免使用 UIMaes。

编辑为了反映我想要完成的任务,

我正在使用 iphone- exif 库 用于编辑主包中图片的元数据。我想将生成的图像保存在照片库中

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"P1080330" ofType:@"JPG"];  
NSData *uiJpeg = [NSData dataWithContentsOfFile:filePath];  
EXFJpeg* jpegScanner = [[EXFJpeg alloc] init];
[jpegScanner scanImageData: uiJpeg];
NSLog(@" EXIF_Make   %@ ", [ jpegScanner.exifMetaData tagValue: [NSNumber numberWithInt:EXIF_Make]]); // OUTPUTS PANASONIC

// Change camera maker to FairyGodmother
[jpegScanner.exifMetaData addTagValue: @"FairyGodmother" forKey:[NSNumber numberWithInt:EXIF_Make]];

NSMutableData *newImageData = [[NSMutableData alloc] init];
[jpegScanner populateImageData:newImageData];

// NOW I HAVE THE NSMUTABLEDATA CONTAINGING MY IMAGE WITH ALL MY EXIF DATA. HOW DO I PUT IT TO THE PHOTO LIBRARY?

I have a NSMutableData containing a JPEG that I want to save in the device library.

I can do it converting it to an UIImage, but then it loses the EXIF data, so UIImaes should be avoided.

EDIT To reflect what I am trying to accomplish

I am using the iphone-exif library to edit the metadata of a picture in my main bundle. I want to save the resulting image in the photo library

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"P1080330" ofType:@"JPG"];  
NSData *uiJpeg = [NSData dataWithContentsOfFile:filePath];  
EXFJpeg* jpegScanner = [[EXFJpeg alloc] init];
[jpegScanner scanImageData: uiJpeg];
NSLog(@" EXIF_Make   %@ ", [ jpegScanner.exifMetaData tagValue: [NSNumber numberWithInt:EXIF_Make]]); // OUTPUTS PANASONIC

// Change camera maker to FairyGodmother
[jpegScanner.exifMetaData addTagValue: @"FairyGodmother" forKey:[NSNumber numberWithInt:EXIF_Make]];

NSMutableData *newImageData = [[NSMutableData alloc] init];
[jpegScanner populateImageData:newImageData];

// NOW I HAVE THE NSMUTABLEDATA CONTAINGING MY IMAGE WITH ALL MY EXIF DATA. HOW DO I PUT IT TO THE PHOTO LIBRARY?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽清梦 2024-12-10 01:01:56

据我所知,UIImageWriteToSavedPhotosAlbum(采用 UIImage)是在设备照片库中获取图像的唯一记录路径。

您对“丢失 EXIF 数据”有何担忧?你是在谈论方向吗? (UIImage 应该会为你处理这个问题。)或者其他 EXIF 数据?

从照片库中获取图像的唯一方法也是作为 UIImage,因此我不确定将原始 JPEG 流推入库中会获得什么。

UIImageWriteToSavedPhotosAlbum (which takes a UIImage) is the only documented path to getting an image in the device's photo library, as far as I know.

What is your concern with "losing EXIF data"? Are you talking about orientation? (UIImage should take care of that for you.) Or other EXIF data?

The only way you can get an image out of the photo library is as a UIImage also, so I'm not sure what you stand to gain by shoving a raw JPEG stream into the library.

蹲在坟头点根烟 2024-12-10 01:01:56

要写入文件,请使用:

[yourImage writeToFile:filePath atomically:YES];

[]'s

To Write a File use:

[yourImage writeToFile:filePath atomically:YES];

[]'s

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文