2

I'm trying to add some extra information to image files when a user takes a picture in iOS. Is there a way to add more key/value pairs to an image's metadata? I've been looking into the ImageIO framework, but everything seems to be a constant. This example in Objective-C is only editing certain pre-existing properties: Is it possible to add own metadata in captured Images in Swift. And this Swift example allows a user to read the metadata stored in an image: iOS 8 Photos framework. Access photo metadata.

Is adding new information to .jpeg images possible? And if so, what is an example in Swift?

Community
  • 1
  • 1
tdon
  • 1,421
  • 15
  • 24
  • `CGImageDestinationAddImage` takes a metadata dictionary. There's also a newer API called CG(Mutable)ImageMetadata and `CGImageDestinationAddImageAndMetadata`. – jtbandes Aug 08 '16 at 18:15
  • It looks as though the keys for the dictionaries available from those libraries here are fixed: https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGImageProperties_Reference/index.html#//apple_ref/doc/constant_group/Individual_Image_Properties. Is there a way to add new properties somehow? – tdon Aug 08 '16 at 18:28
  • What prevents you from using your own keys? Have you tried it? – jtbandes Aug 08 '16 at 18:29
  • From the documentation: "The dictionary can contain any of the properties described in “Destination Properties” or the image properties described in CGImageProperties Reference." https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGImageDestination/#//apple_ref/c/func/CGImageDestinationAddImage – tdon Aug 08 '16 at 18:59
  • Long shot. Ever figure this out? – shoe Dec 31 '22 at 07:01
  • @shoe It's been a long time since I've worked on this, but I believe the I ended up using an existing field to store the data. – tdon Jan 25 '23 at 07:21
  • I see. So shoehorning data into a supported metadata field that's actually intended for something else, and then just keeping track of the unorthodox usage of the field? – shoe Jan 28 '23 at 19:55
  • I found something that was "close enough" for my particular use case. From what I remember there was more involved in creating custom EXIF data fields, so using an existing one was more expedient for me at the time. – tdon Jan 28 '23 at 23:59

0 Answers0