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
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]);
}];
}
I ran a test comparing images using both options. Using option 1, the image was twice as big (4.22 MB vs 2.04 MB). Looking at the photos in Photoshop, there didn't seem to be any major difference in quality. When looking at the levels, the one created by option 1 was not as smooth (Image below). when looking at the files properties, the one created by option 1 was missing some "origin", "camera", and "advanced photo" options that the file created by option 2 had. I haven't decided which way I am going to use but hopefully this info will help someone else!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With