AgnosticDev
AgnosticDev

Reputation: 1853

Objective-C Camera Crop Size

I have a routine that I use to trigger the camera to take a photo. After the camera takes the photo the user is then given an option to crop the image by default before the delegate passes me back the UIImage. Is there any way that I can pass in a dynamic CGRect to make this default crop area a specific size? One thing I should mention is that the application is a landscape iPad application.

Here is a code sample:

-(void)triggerCamera:(id)sender
{
    UIImagePickerController *camera = [[UIImagePickerController alloc] init];
    camera.delegate = self;
    camera.allowsEditing = YES;
    camera.sourceType = UIImagePickerControllerSourceTypeCamera;
    //pass in some sort of CGRect ??
    [self presentViewController:camera animated:YES completion:NULL];
}


-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info {

    UIImage *img = [info objectForKey: UIImagePickerControllerOriginalImage];
    //process my image further
}

Upvotes: 0

Views: 930

Answers (2)

Corey
Corey

Reputation: 5818

Maybe take a look at GKImagePicker on GitHub. This project hasn't had much activity in the past few months (maybe more), but could be worth a shot. It even comes with an option to have a resizable crop area. I have not tried it myself, but the implementation looks to be pretty simple:

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

[self presentModalViewController:self.imagePicker.imagePickerController animated:YES];

Upvotes: 2

Josip B.
Josip B.

Reputation: 2464

Unfortunately you can't set crop size. I was dealing with same problem over 2 years ago and I got stuck with creating my own viewController for cropping image.

Upvotes: 2

Related Questions