On iPhone, I saved the image in the photo library with the changes (adding data after the image code) using the assest library to save the NSData directly in the photo library. Now I want to read the image from the photo library as NSData in order to read it. If I read it as a UIImage, it will change the data inside the image.
How can I read a photo from a photo library like NSData? I tried to look at the link url in 4.1 but no luck.
Edit: I edited to explain why I save it as NSData. The URL method in the answers works if you just need pure NSData but it doesnβt help in the context that I am asking for.
Edit 2: The answer with getBytes was the answer that did this for me. The code I used was:
int8_t *bytes = malloc([representation size]); NSUInteger length = [representation getBytes:bytes fromOffset:0 length:[representation size] error:&error];
This allowed me to get everything inside the file that gave me the PLUS image code, which I added in the form of NSData.
Edit 3:
Is there a way to do this now in iOS 10 using PHPhotoLibrary, which replaces AssetLibrary? I need the image in NSData to be the original RAW image without any changes.
iphone xcode uiimage uiimagepickercontroller nsdata
SolidSnake4444
source share