电子邮件jpg在应用程序中创建,包括元数 [英] Email jpg created in app including metadata
问题描述
我已成功添加元数据到应用程序内创建的jpg,并使用
I have successfully added metadata to a jpg created within the app and saved it to the Camera Roll using the
writeImageToSavedPhotosAlbum: metadata: completionBlock:
方法。不过我也希望通过电子邮件发送这个jpg与元数据(如位置,退出等)。我使用这个电子邮件:
method. However I would also like the option of emailing this jpg with the metadata (such as location, exit, etc.). I use this to email:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSData *myData = UIImageJPEGRepresentation(emailImage, 0.8);
[picker addAttachmentData:myData mimeType:@"image/jpg" fileName:@"photo"];
但是,这不会导致元数据。
发送保存的图像时通过苹果的照片应用程序,包含元数据 。
有没有办法将元数据嵌入到NSData附件中?任何想法?
However, this results in no metadata.
When the saved image is sent via Apple's photo app, metadata is included.
Is there a way to embed the metadata into NSData attachment? Any ideas?
推荐答案
UIImage不持有任何元数据。如果您有图像的路径直接从它读取数据。如果从相机胶卷中获取图像,那么UIImagePickerDelegate中还包含信息字典中的元数据的 imagePickerController:didFinishPickingMediaWithInfo:
方法。
UIImage doesn't hold any metadata. If you have the path for the image read data directly from it. If you get the image back from camera roll there's the imagePickerController:didFinishPickingMediaWithInfo:
method from UIImagePickerDelegate which also contains the metadata inside the info dictionary.
此外,mimeType应为image / jpeg。
Also the mimeType should be "image/jpeg".
编辑:
要添加元数据到 UIImage
,您可以使用ImageIO框架:您可以从UIImage创建一个 CGImageDestination
对象,使用 CGImageDestinationSetProperties
然后从中获取原始数据(包括压缩图像和元数据)
To add metadata to a UIImage
you can use the ImageIO framework: You can create a CGImageDestination
object from a UIImage, add metadata to it using CGImageDestinationSetProperties
and then get the raw data (which includes the compressed image and the metadata) from it
这篇关于电子邮件jpg在应用程序中创建,包括元数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!