Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change the UIImagePickerController crop frame

when opening working with an UIImagePickerController and setting allowsImageEditing = YES; there is a default cropping frame that is 320x320. In my case, I would like to setup that cropping frame to 320x240 for images that are landscape, and 240x320 for images that are portrait. However, I haven't been able to find a way to change that 320x320 frame that is used when editing /cropping a photo. Has any of you found a way to do it?

Thanks!

like image 664
user123404 Avatar asked Jun 15 '09 22:06

user123404


3 Answers

You have to implement it your self.

The picker only performs 320x320 cropping.

So instead set

allowsImageEditing = NO;

Now you will get the full image back. Then you will have to create a view/view controller that will crop to the proportions you desire.

like image 54
Corey Floyd Avatar answered Nov 20 '22 04:11

Corey Floyd


This is the more recent answer with the necessary manual cropping code: Manual Crop

There is still no escaping the hard work.

like image 38
Tim Avatar answered Nov 20 '22 02:11

Tim


You can try ShittyImageCrop. It's good for cropping to a specific aspect ratio. In your case, present it with aspect ratio 4:3 (or 3:4 in landscape) like this:

let cropVC = ShittyImageCropVC(frame: (self.navigationController?.view.frame)!, image: imageToCrop, aspectWidth: 4, aspectHeight: 3)
self.navigationController?.present(cropVC, animated: true, completion: nil)

After that you can use some other code to just scale it to desired resolution (320x240 or 240x320).

like image 3
budiDino Avatar answered Nov 20 '22 02:11

budiDino