I need to get the meta data of the image from the library. I am using the code
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:assetURL resultBlock:^(ALAsset *asset) {
ALAssetRepresentation *representation = [asset defaultRepresentation];
metadataDict = [representation metadata];
NSLog(@"%@",metadataDict);
} failureBlock:^(NSError *error) {
NSLog(@"%@",[error description]);
}];
[library release];
}
I am using IOS 4.2 But I am not getting the meta data.Can any one help me with this?
There doesn't seem to be anything wrong with the code you posted. I have tried it in the simulator and on a device and it works. Apple's documentation for the metadata
method states:
Returns nil if the representation is one that the system cannot interpret.
So this most likely means that the image you have chosen either doesn't have any metadata or the the image is in a form that the library doesn't recognize.
You have not defined metadataDict
in your method so if you want to use outside of your block you have to retain it.
metadataDict = [[representation metadata] retain];
Possibly you have have to declare it with the __block
identifier as well.
__block NSDictionary *metaDataDict;
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