Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use CGImageMetadataRef?

I'm looking for an example using the new APIs in 10.8 called (CGImageMetadataRef) that allow fast lookup of image metadata.

It's something along these lines, but I'm too new with the APIs to know where I'm going wrong.

CGImageSourceRef source = CGImageSourceCreateWithDataProvider(provider, NULL);
CGImageMetadataRef mr = CGImageSourceCopyMetadataAtIndex(source, 0, NULL);
like image 764
akaru Avatar asked Dec 18 '25 21:12

akaru


1 Answers

Once you have a valid CGImageMetadataRef, you can use, for example, CGImageMetadataCopyTags to get an array of the metadata tags:

CGImageSourceRef source = ...
NSArray *metadataArray = nil;

if (source) {
    CGImageMetadataRef metadata = CGImageSourceCopyMetadataAtIndex(source, 0, NULL);
    if (metadata) {
        metadataArray = CFBridgingRelease(CGImageMetadataCopyTags(metadata));
        CFRelease(metadata);
    }
    CFRelease(source);
}

return metadataArray;
like image 100
Rob Avatar answered Dec 24 '25 06:12

Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!