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.
Asked
Active
Viewed 1,034 times
0
-
possible duplicate of [How to get image metadata in ios](http://stackoverflow.com/questions/12478502/how-to-get-image-metadata-in-ios) – Malloc Jul 18 '14 at 02:02
-
@Malloc not a dupe because the other post doesn't address custom metadata? we specifically need custom metadata. – Crashalot Jul 18 '14 at 02:10
1 Answers
3
You can use ImageIO framework to retrieve metadata of an image.
- Make sure you add ImageIo framework
#import <ImageIO/ImageIO.h>
- Retrieve the metadata from local file or remote URL. Change the URL if you're using remote URL
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.

Subhransu
- 108
- 4
-
1@Crashalot yes if you just want to retrieve custom metadata the above code should work. Refer to the sample code of [ImageApp](https://developer.apple.com/library/mac/samplecode/ImageApp/Listings/ImageInfoPanel_m.html) if you have some other requirements. But basically **ImageIO** is the answer! – Subhransu Jul 18 '14 at 03:27
-