How do I record a maker note or user comment in EXIF?

可紊 提交于 2019-12-31 04:43:09

问题


I'm building a camera app, and want to record in the EXIF the settings that the user selected. Most settings have standard fields, but one doesn't, so I thought I'll record it in the maker notes field.

I tried

let attachments = NSMutableDictionary(dictionary: CMCopyDictionaryOfAttachments(nil, buffer, kCMAttachmentMode_ShouldPropagate) as! NSDictionary)

let exif = NSMutableDictionary(dictionary: attachments[kCGImagePropertyExifDictionary] as! NSDictionary)

exif[kCGImagePropertyExifMakerNote] = "Blah blah"

attachments[kCGImagePropertyExifDictionary] = exif

But when I try

exiftool photo.JPG | grep -i maker

or

exiftool photo.JPG | grep -i blah

I don't see the note. All other properties I set in EXIF are showing up.

I then tried setting it as a user comment, as suggested in this answer:

let comment = ["My custom setting": "blah"]

exif[kCGImagePropertyExifUserComment] = comment

This doesn't work either.

Am I setting the format of the maker note wrong? Isn't it a string? What about the user comment?

Or is there some other field in EXIF that I should be using instead of maker notes or user comment?

来源:https://stackoverflow.com/questions/42468315/how-do-i-record-a-maker-note-or-user-comment-in-exif

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!