Iphone 获取CGImageSourceRef的图像路径

Iphone 获取CGImageSourceRef的图像路径,iphone,objective-c,xcode,exif,Iphone,Objective C,Xcode,Exif,嘿,伙计们,我正在尝试从用户通过UIIMagePickerController选择的图像中获取EXIF数据。我似乎无法理解如何获得可用于CGImageSourceCreateWithURLCFURLRefsomeURL的路径,nil 当我尝试使用UIImagePickerControllerReferenceURL时,控制台抛出了一个相当不错的错误:CGImageSourceCreateWithURLCFURLCreateDataAndPropertiesFromResource失败,错误代码为

嘿,伙计们,我正在尝试从用户通过UIIMagePickerController选择的图像中获取EXIF数据。我似乎无法理解如何获得可用于CGImageSourceCreateWithURLCFURLRefsomeURL的路径,nil

当我尝试使用UIImagePickerControllerReferenceURL时,控制台抛出了一个相当不错的错误:CGImageSourceCreateWithURLCFURLCreateDataAndPropertiesFromResource失败,错误代码为-11。。我被难住了,我开始认为我从一个完全错误的角度出发,因为CGImageSourceRef类型通常用于创建图像,而我已经有了一个UIImage。任何人如果能对这件事有所了解,请随时这样做

-voidimagePickerController:UIImagePickerController*PickerdFinishPickingMediaWithInfo:NSDictionary*信息 {

-编辑-
将使用more tension提供的解决方法。感谢阅读。

错误代码-11表示URL方案无法识别,也就是说CFURL不知道如何处理以assets library:///开头的URL

在这种情况下,您为什么认为需要CGImageSourceRef?

尝试使用

ALAssetRepresentation*representation=[yourAsset defaultRepresentation];
NSDictionary*metadataDict=[[表示元数据]保留]因为我计划使用ImageIO框架从图像中读取EXIF数据。此CGImageSourceCopyPropertiesAtIndex的方法需要一个作为参数传递的CGImageSourceRef对象。我想我还需要使用一个CGImageSourceRef,它实际上是对图像的引用,由UIImagePickerController返回。我只是不知道现在,我将着手检索正确的URL。我认为资产URL不是我想要的,因为我尝试了ALAsset框架,但结果是不够。解决方法可能是在本地保存原始图像数据,然后使用CGImageSourceCreateWithURL获取CGImageSource。嗯,这可能是一种可能性,我没有o确保通过该过程保留所有EXIF数据,但非常感谢!如果这对您有帮助,您应该+1 bump@more_tension。我对实际答案进行了碰撞,它稍微向下一点:[表示元数据]不会返回所有EXIF信息,如相机品牌或光圈等。。
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
[self dismissModalViewControllerAnimated:YES];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]){
    image = [info objectForKey:UIImagePickerControllerOriginalImage];
    NSLog(@"%@",[info objectForKey:UIImagePickerControllerReferenceURL]);
    //Outputs: assets-library://asset/asset.JPG?id=1000000006&ext=JPG
    CGImageSourceCreateWithURL((CFURLRef)[info objectForKey:UIImagePickerControllerReferenceURL], nil);

    //The plan is to somehow get a CGImageSourceRef object from the 
    //UIImage provided by the [info UIImagePickerControllerOriginalImage], i just don't know how to get this object,
    // for it requires the URL to the image, wich i don't seem to have.
    }

}