Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove square ratio cropping for images on IOS

I am using the IOS standard image cropping functionality (move and scale) to crop my image before submitting it to the server.

However, I realize that the cropping provided has a square ratio (see screenshot below)

enter image description here

Snippet of the code is as follows:

//set up image picker
self.imgPicker = [[[UIImagePickerController alloc] init]autorelease];
self.imgPicker.allowsEditing = YES;
self.imgPicker.delegate = self;

//Trigger get photo from library function
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:self.imgPicker animated:YES];

How can allow 'move and scale' editing and at the same time allow the user to do cropping WITHOUT the square ratio restriction?

like image 468
Zhen Avatar asked Apr 13 '12 02:04

Zhen


People also ask

How do I make a picture Square on a Mac?

Crop or straighten the photo automatically: Click Auto. Crop manually: Drag the selection rectangle to enclose the area you want to keep in the photo. Crop to specific proportions: Click Aspect, then choose the aspect ratio you want. For example, for a square photo, choose Square.


2 Answers

I think you need change self.imgPicker.allowsEditing = YES; to self.imgPicker.allowsEditing = NO;

like image 80
Alex Avatar answered Oct 20 '22 00:10

Alex


This library can help you.

https://github.com/gekitz/GKImagePicker

It supports custom cropping and it's easy to integrate with the native picker if needed.

like image 33
Gui Moura Avatar answered Oct 20 '22 00:10

Gui Moura