I have an implementation of AVCaptureSession and my goal is for the user to take a photo and only save the part of the image within the red square border, as shown below:
Swift 3:
let imageRef:CGImage = uncroppedImage.cgImage!.cropping(to: bounds)! let croppedImage:UIImage = UIImage(cgImage: imageRef)