Crashalot
Crashalot

Reputation: 34503

Is there a way to extract custom metadata from a PNG file with Objective-C?

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

Answers (1)

Subhransu
Subhransu

Reputation: 108

You can use ImageIO framework to retrieve metadata of an image.

  1. Make sure you add ImageIo framework
  2. #import <ImageIO/ImageIO.h>
  3. 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.

Upvotes: 3

Related Questions