How to crop an image after shooting with a UIImagePicker camera?

I am trying to allow the user to use a 16 percent aspect ratio of the image so that they look like good HD photos. I use cameraViewOverlay to overlay black bars at both ends, but when the image is running, how do I crop top and bottom without resizing or zooming?

Thanks.

+6
iphone camera uiimagepickercontroller crop
source share
3 answers

There are various posts on how to scale / crop the UIImage that you return from the camera, like this one .

This is a bit more complicated than you expected, because the camera images rotate, so you need to think about rotations, even if you just crop.

+2
source share

you can add "picker.imageEditing = YES" to your code when you take an image. Then you must set the imageView properties in the interface builder: Image attributes → View → Mode → Aspect is suitable or another option, as you wish

+1
source share

Check out this Ming Yang solution. https://github.com/myang-git/iOS-Image-Crop-View

It allows the user to crop the image by moving or dragging the edges of the rectangle around the desired part of the image. I assume that this code can be changed according to your needs, be it automatic or manual.

It is encoded in Objective-C. You may need to either encode it in Swift or just build a bridge header to connect Objective-C code with Swift code.

+1
source share

All Articles