Retrieve Modified Image Metadata from iCloud Photo Library

I am currently retrieving images (and associated metadata) from the iCloud photo library using the Photos framework (PhotoKit) and the following code:

    PHAsset *asset = ...;

    PHImageRequestOptions *options = [PHImageRequestOptions new];
    options.networkAccessAllowed = YES;
    options.version = PHImageRequestOptionsVersionCurrent;
    options.resizeMode = PHImageRequestOptionsResizeModeNone;
    options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat; // ignored by requestImageDataForAsset

    self.requestID = [self.imageManager requestImageDataForAsset:asset options:options resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
        if (imageData) {
            NSDictionary *metadata = nil;

            CGImageSourceRef sourceRef = CGImageSourceCreateWithData((CFDataRef)imageData, NULL);
            if (sourceRef) {
                CFDictionaryRef dictionaryRef = CGImageSourceCopyPropertiesAtIndex(sourceRef, 0, NULL);
                if (dictionaryRef) {
                    metadata = (__bridge NSDictionary *)dictionaryRef;
                    CFRelease (dictionaryRef);
                }
                CFRelease (sourceRef);
            }

            NSLog("metadata = %@", metadata);

            self.requestID = PHInvalidAssetResourceDataRequestID;
        }
    }];

The problem I encountered is that the metadata returned is from the source file. It does not contain any changes to the name, description or keywords made using the Photos app (these items are stored in the {IPTC} category.)

The header documentation for -requestImageDataForAsset:options:resultHandlerindicates that it PHImageRequestOptionsVersionCurrentcan be used to retrieve the edited rendered image, but this does not seem to apply to metadata settings.

? , "" Mac, , , iOS.

+4

All Articles