Reputation: 34503
Is there a way to extract custom metadata from a PNG file with Objective-C? Other StackOverflow posts have libraries for Java or other languages, but none for Objective-C. We need to extract custom metadata from a PNG file from within an iOS app. The user choose an image from his/her Photo Gallery, and we will extract the custom metadata.
Upvotes: 0
Views: 1048
Reputation: 108
You can use ImageIO framework to retrieve metadata of an image.
#import <ImageIO/ImageIO.h>
NSURL *localFileUrl = [[NSBundle mainBundle] URLForResource:@"myImage" withExtension:@"png"]; CGImageSourceRef imageSource = CGImageSourceCreateWithURL((__bridge CFURLRef)localFileUrl, NULL); NSDictionary* imageProperties = (__bridge NSDictionary*) CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); NSLog (@"image meta data %@", imageProperties);
Refer to ImageI/O programming guide if you want to do more advanced stuffs.
Upvotes: 3