How to get image metadata in ios
CGImageSourceRef source = CGImageSourceCreateWithURL( (CFURLRef) aUrl, NULL);CGImageSourceRef source = CGImageSourceCreateWithData( (CFDataRef) theData, NULL);NSDictionary* metadata = (NSDictionary *)CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(source,0,NULL));CFRelease(source);
Check the dictionary contents here.
Here is code, to get meta data from an image path:
NSData *imagedata = [NSData dataWithContentsOfFile:imagePath];CGImageSourceRef source = CGImageSourceCreateWithData((CFMutableDataRef)imagedata, NULL);NSDictionary *metadata = [(NSDictionary *)CGImageSourceCopyPropertiesAtIndex(source,0,NULL)autorelease];
Or, if using swift 4.0:
var imagedata = Data(contentsOfFile: imagePath) var source: CGImageSourceRef = CGImageSourceCreateWithData((imagedata as? CFMutableDataRef), nil) var metadata = CGImageSourceCopyPropertiesAtIndex(source, 0, nil) as? [AnyHashable: Any]