Muthu Sabarinathan
Muthu Sabarinathan

Reputation: 1208

How to crop image from camera preview view in swift 3?

I have a camera view and top of that I placed one blue rectangle line imageview.

enter image description here

My Questions is, when I press the capture button I have to save the image whatever is inside the rectangle area. I tried with below mentioned code but it doesn't crop that area.

let cgImage = image.cgImage
let croppedCGImage: CGImage = cgImage!.cropping(to: self.m_TrimArea.frame)!
let uiImage = UIImage(cgImage: croppedCGImage)

Here self.m_TrimArea is an imageview which holds the blue rectangle line. Please give some guidance to achieve this.

Upvotes: 0

Views: 2877

Answers (1)

Riyan Fransen
Riyan Fransen

Reputation: 554

I would suggest you use the following pod. https://cocoapods.org/pods/Toucan

Upvotes: 1

Related Questions