Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Metadata for the image from library

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?

like image 402
PgmFreek Avatar asked Nov 06 '22 05:11

PgmFreek


1 Answers

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;
like image 132
Robert Höglund Avatar answered Nov 09 '22 13:11

Robert Höglund