iosmetadatajpegexifcgimage

Modifying JPEG Metadata without Recompressing Image in iOS


I'm trying to use

CGImageSourceCreateWithData CGImageDestinationCreateWithData

and then

CGImageDestinationAddImageFromSource

but this discards any thumbnails or other embedded information in the original file. What I want to do is read in the file, alter its metadata, and write it out with the alterations only. But I'll settle for reading everything out of it, and putting it back again. Right now a 1.2MB image file gets converted to a 437kB file with the loss of additional data.

Is there something other than CGImage I can use? Can this even be done with the iOS API?


Solution

  • What I was looking for was a read-modify-write operation for image files that allowed changes but otherwise maintained unaltered data. I've determined through research and testing that this is not possible in iOS. The closest mechanism available is CGImage processing, but this only allows you to read selected information from a source image (such as image, thumbnail, properties), and then use some of that information (image, properties) to create a new destination file. There's no way to include a thumbnail in the new destination file, and no way to get around recompressing the image.