In the app that I am developing, I am using an image that a user chooses from their photo albums. I need to upload a hi-res version of that photo to my server.
I'm using imagePickerController and I've determined that I have 2 options
- use UIImage from UIImagePickerControllerOriginalImage
- get original asset by using UIImagePickerControllerReferenceURL and ALAssetsLibrary assetForURL (I don't like this because it prompts the user to use their current location, which I don't need)
My question is... Is there any difference in the quality of the image if I use the first option vs the second?
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
//option 1
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
NSData *imgData = UIImagePNGRepresentation(image);
// option 2 (will prompt user to allow use of current location)
NSURL *imgURL = [info objectForKey:@"UIImagePickerControllerReferenceURL"];
__block NSData* imgData;
ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init];
[assetLibrary assetForURL:img resultBlock:^(ALAsset *asset)
{
ALAssetRepresentation *rep = [asset defaultRepresentation];
Byte *buffer = (Byte*)malloc(rep.size);
NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:rep.size error:nil];
imgData = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];
}
failureBlock:^(NSError *err) {
NSLog(@"Error: %@",[err localizedDescription]);
}];
}