How to write or modify EXIF data for an existing i

2020-02-09 16:18发布

问题:

I've asked similar questions before, but have not received a definitive answer. Seems that there must be a way to simply add/modify metadata to an image without loading the image into memory, without having to deal with directly reading bits.

Seems like ways exist when using CMSampleBufferRefs, but I need to be able to do this with a regular image already saved to disk.
For instance, given a very large png at /Documents/photo.png, I want to modify its exif metadata without having to load that image.

回答1:

You can use libexif - I've had success with compiling it for iOS before. With libexif, you can modify any image's EXIF metadata.



回答2:

If you know how to modify the EXIF, you can modify the binary data directly from the file. Just replace in the image the binary portion with the new one. I don't know if objective-c permit this, but in ansi c should be simple. The complicate part is to identify the exact part to change.