1
votes

I'm struggling to figure out how I can obtain an image from a UIImagePickerControllerReferenceURL (I know that I can obtain it directly from UIImagePickerControllerOriginalImage however, I have reasons for wanting not to). Here's what I have

/* 
 *   Responds when an image is selected (from browsing)
 */
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{        
        UIImage *image = [self obtainImageAtURLPath:[info objectForKey:UIImagePickerControllerReferenceURL]];
        if(!image) return;
        //...more code here
}
- (UIImage *) obtainImageAtURLPath:(NSURL *) urlPath
{
    UIImage *image = [UIImage imageWithContentsOfFile:[urlPath path]];
    return image;
}

However, when I do this, I always get nil instead of my image. The urlPath exists; however, it doesn't want to be converted to a UIImage. Help please.

If I print out NSLog(@"%@", urlPath) I get assets-library://asset/asset.JPG?id=53784678-BD17-4EE4-9A96-601B81012AFE&ext=JPG

If I print out NSLog(@"%@", [urlPath path]) I get /asset.JPG.

1
What kind of image is it? Show the URL - Dustin
It's an image that was taken using the iPad camera. I'll post the actual path in just a sec - Nosrettap
@Dustin see actual path in edit above. Thanks - Nosrettap
That's why; depending on the iOS you're running apple won't just let you access camera info. Try using a different URL to something you have access to and see if it works. - Dustin
Try using the AssetsLibrary framework agilewarrior.wordpress.com/2012/02/06/… - Dustin

1 Answers

0
votes

I've answered a similar question here:name of the picked image xcode. You should use ALAssetsLibrary to load that image asset using that kind of urlPath.