19

I'm using the UIImagePickerController to take and edit a picture. it works fine in landscape, but in portrait it will crop the picture into a square (does not allow to reduce the image to fit fully into the square crop field like in landscape. Any ideas?

code:

-(IBAction)initCamera:(id)sender{

//Init imagePicker instance
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setDelegate:self];

[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setShowsCameraControls:YES];
[imagePicker setAllowsEditing:YES];

[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
}
j7nn7k
  • 17,995
  • 19
  • 78
  • 88
cabhara
  • 463
  • 1
  • 4
  • 14

3 Answers3

12

Check out GKImagePicker library, it allows to set your custom image crop area, like this:

self.imagePicker = [[GKImagePicker alloc] init];
self.imagePicker.cropSize = CGSizeMake(320, 90);
self.imagePicker.delegate = self;

[self presentModalViewController:self.imagePicker.imagePickerController animated:YES];
Andrey Zverev
  • 4,409
  • 1
  • 28
  • 34
12

I know its really late to answer this question, But someone may find this helpful.

Change

[imagePicker setAllowsEditing:YES]; 

To

[imagePicker setAllowsEditing:NO];

Thanks, Jay

Jay Pandya
  • 507
  • 6
  • 26
  • This simply disables cropping. Imagine a use-case where someone wanted to upload a full-size portrait, yet wanted to crop out parts of a landscape photo. – carbocation Oct 11 '15 at 17:59
  • @carbocation yes that can be a case. But thats whole new functionality i guess, that you can manage by checking **imageOrientation** property of image in `didFinishPickingImage:` delegate method of `UIImagePickerController` – Jay Pandya Oct 13 '15 at 05:28
4

You can provide a custom cropping UI, but there is no way to change just the cropping rectangle of the standard one.

This link might help with that.

Peter Sarnowski
  • 11,900
  • 5
  • 36
  • 33
  • 1
    Thanks. I'm just wondering why cropping works ok for landscape (I can fit the whole image into the cropping square, so nothing gets lost), but not for portrait, where it doesn't allow to fit the image into the square. – cabhara Feb 20 '12 at 14:49