【问题标题】:iphone image detail (selected from photo library)iphone图像细节(从照片库中选择)
【发布时间】:2012-03-06 16:12:24
【问题描述】:

我想获取我从 iphone 库中选择的图像的所有细节 喜欢

  1. 图像名称

  2. 图片路径

  3. 图片类型

  4. 图像大小

  5. 图像 ID

我选择了像

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

然后选择图片

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

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

对于路径我已经尝试过了,但没有得到正确的路径

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

需要帮助...

回复

谢谢..

【问题讨论】:

    标签: iphone ios image path uiimagepickercontroller


    【解决方案1】:

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

    【讨论】:

    • 不是真正的答案,您应该将其添加为评论。
    • @rckoenes 对新手友好一点。 iPhoneNerd:欢迎来到 StackOverflow。我认为你是对的,ALAsset 应该提供更多信息(但不是真正的路径信息),但正如 rckoenes 所提到的,这还不足以作为答案。请把它作为评论并删除答案。
    • @fzwo 谢谢..但是我真的不明白 ALAsset 到底是什么..你能给我举个例子吗.. ??
    • @Vivek2012 这不是我的建议,而是 iPhoneNerd 的建议。 ALAsset 是一种代理对象,代表库中的图像或视频。这一切都在文档中进行了解释。但我认为它可能对您没有太大帮助,因为有些东西您永远无法访问,例如路径。我认为你应该阅读 ALAssetsLibrary(iOS 中的照片库),并决定你想做什么,你需要什么,以及如何获得你需要的东西。你不会得到路径,我认为你不需要它。
    • @fzwo 你知道任何替代方法吗.. 我的主要目标是获取图像路径、大小、名称和类型.. 你会帮我吗??
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      试试这个

         - (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];
      }
      

      您还必须使用 __block 标识符声明它。

             __block NSDictionary *metaDataDict;    
      

      【讨论】:

        猜你喜欢
        • 2012-03-21
        • 2016-11-01
        • 2017-09-06
        • 2020-10-02
        • 2012-06-26
        • 1970-01-01
        • 2014-04-23
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多