I want to display image metadata using ios. Meta data like Aperture, Shutterspeed, Exposure Compensation, ISO, Lens Focal Length, etc. So please help me if anybody has idea.
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With