简体   繁体   中英

iphone image detail (selected from photo library)

i want to Get all detail of image which i have select from iphone library like

  1. Image name

  2. image path

  3. Image type

  4. image size

  5. image ID

I have select image like

   picker1 = [[UIImagePickerController alloc]init];
    picker1.delegate = self;
    picker1.allowsEditing= YES;
    //picker1.showsCameraControls = YES;
    picker1.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentModalViewController:picker1 animated:YES];
    [picker1 release];

and then for selected image

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info;
{
    isImage = TRUE;

    image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    sendimageview.image=image;
    appDelegate.mediabuttonpress=TRUE;
}

and for path i have try this but not getting proper path

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *strPath= [paths objectAtIndex:0];
 strPath = [strPath stringByAppendingPathComponent:imageName];
 NSLog(@"*******Path %@",strPath); 

Need Help ...

Reply

Thanks ..

Try this

   - (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] retain]; 
   NSLog(@"%@",metadataDict);


  } failureBlock:^(NSError *error) {
   NSLog(@"%@",[error description]);
  }];
[library release];
}

you have have to declare it with the __block identifier as well.

       __block NSDictionary *metaDataDict;    

我认为您必须使用ALAsset类,因为我不确定UIImage是否提供您需要的所有信息(尤其是GPS信息)。

您无法从库中获取图像的“真实”路径,即使可以获取,也无法访问。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM