Read and write images metadata using
ImageIO and easy to use models.
// load metadata from original file SYMetadata *metadata = [SYMetadata metadataWithFileURL:imageURL]; // create IPTC container if not present if (!metadata.metadataIPTC) metadata.metadataIPTC = [[SYMetadataIPTC alloc] init]; // edit metadata metadata.metadataIPTC.keywords = @[@"Some test keywords", @"added by SYMetadata example app"]; metadata.metadataIPTC.city = @"Lyon"; metadata.metadataIPTC.credit = @"© Me 2017"; // create new image data with original image data and edited metadata NSData *data = [NSData dataWithContentsOfURL:imageURL]; NSData *dataWithMetadata = [SYMetadata dataWithImageData:data andMetadata:metadata]; // load metadata for newly cerated image SYMetadata *metadataNew = [SYMetadata metadataWithImageData:dataWithMetadata]; // log the delta in file size NSLog(@"Delta: %ld bytes", (unsigned long)dataWithMetadata.length - (unsigned long)data.length); // log the differences between files NSLog(@"Differences:\n%@", [NSDictionary sy_differencesFrom:metadata.originalDictionary to:metadataNew.originalDictionary includeValuesInDiff:YES]);
Keep in mind
When saving metadata to a file you can encouter the following issues:
- metadata was not written
- metadata was modified a bit
- metadata was added
This library uses
ImageIO which has its own limitations and performs its own value checks. This is just a wrapper around the
NSDictionary structure this framework exposes and is not perfect. Please heavily test your app if you use this library to edit metadata, a set of test images for tests can be found in the example app (currently testing around 216 keys out of 314 supported on iOS 10.2). This library DOES NOT garantee data integrity like
You'll find links that helped me a lot in comments inside this library where appropriate. Mainly:
Credits to chrfb (http://chrfb.deviantart.com) for the beautiful icons I used in the tab buttons.
Use it as you like in every project you want, redistribute with mentions of my name and don't blame me if it breaks :)