/CGImageMetadata

Add Metadata to UIImage

Primary LanguageSwift

Add GPano and Custom Metadata to Image in Swift 3

Swift still doesn't support XMP tag yet. So it seems that we have no way to add GPano information to an image.
But!!!!! Finally I got a tricky way!!

First. I still don't know how to make a CGImageMetadata.
So I made a very small image which has been injected GPano metadata by this tool(https://www.thexifer.net/#geo-tags).
Then put it in the bundle, load it as an imageSource.
IMPORTANT Don't use UIImage. The UIImage will remove all metadata you add!!

Next, change CGImageMetadata into mutableMetadata.
That's all!
You can add metadata string you want e.g.
CGImageMetadataSetValueMatchingImageProperty(mutableMetadata!, kCGImagePropertyTIFFDictionary, kCGImagePropertyTIFFMake, "Make e.g. Ricoh" as CFTypeRef)

Hope that useful to you!!

Please let me know if there is a formal way to achieve this in new version of Swift!