1

In my app you pick an image using UIImagePickerControllerDelegate, so I have an UIImage. Now I need the filepath of said image.

More about the app: I'm trying to modify/edit a selected PNG image. I need to be able to access each pixel of chosen image. I have found source code on how to access the pixels but the code relies on loading the image via filepath and I haven't found any way of using the UIImage instead. I've tried:

CGImageRef si = [imageView.image CGImage];
CGDataProviderRef src = CGImageGetDataProvider(si);
CGImageRef img = CGImageCreateWithPNGDataProvider(src, NULL, NO, kCGRenderingIntentDefault);

But that only gives me the error: ": CGDataProviderGetSize: size is too large for this function."

(See iPhone SDK: accessing indexed color PNG images )

1 Answer 1

1

When the image is picked, your delegate gets a callback on imagePickerController:didFinishPickingMediaWithInfo: That call includes an info parameter which is a dictionary. One of the keys gives you the file URL. A file URL can be converted to a path using the path method.

Sign up to request clarification or add additional context in comments.

1 Comment

I saw in the documentation that that method signature was deprecated but using the correct signature - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info only gives me the keys and values "key: UIImagePickerControllerMediaType, value: public.image key: UIImagePickerControllerOriginalImage, value: <UIImage: 0x392e680>"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.