0

I am new in XCode, I want to select a photo from photo library.

- (void) ChoosePhoto_from_Album
{
    UIImagePickerController *imgage_picker = [[UIImagePickerController alloc] init];
    imgage_picker.delegate = self;
    imgage_picker.allowsEditing = YES;
    imgage_picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentViewController:imgage_picker animated:YES completion:NULL];
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
      UIImage *  image = [info objectForKey:UIImagePickerControllerOriginalImage];

      NSLog(@"ImagePicker image size = (%.0f x %.0f)", image.size.width , image.size.height);
      // process image...
}

The photo I selected is 5MP (2592x1936). However, it return the size is 960x716. What I am missing ?

Thanks !

rmaddy
  • 314,917
  • 42
  • 532
  • 579
peterho
  • 74
  • 1
  • 3

2 Answers2

0

I found this link. You can use the Three20 Framework by using following contains the codes.

Here is your solution.

Community
  • 1
  • 1
Ravi Kumar Karunanithi
  • 2,151
  • 2
  • 19
  • 41
0

UIImagePickerController does give you the full camera based image. You need to get it from the editingInfo parameter of the imagePickerController:didFinishPickingImage:editingInfo method.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
 CGImageRef ref = image.CGImage;
 int width = CGImageGetWidth(ref);
 int height = CGImageGetHeight(ref);
 NSLog(@"image size = %d x %d", width, height);

 UIImage *orig = [editingInfo objectForKey:UIImagePickerControllerOriginalImage];
 ref = orig.CGImage;
 width = CGImageGetWidth(ref);
 height = CGImageGetHeight(ref);
 NSLog(@"orig image size = %d x %d", width, height);

 CGRect origRect;
 [[editingInfo objectForKey:UIImagePickerControllerCropRect] getValue:&origRect];

 NSLog(@"Crop rect = %f %f %f %f", origRect.origin.x, origRect.origin.y, origRect.size.width, origRect.size.height);
}
Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102