title: How to crop image from camera preview view in swift 3?
body: <p>I have a camera view and top of that I placed one blue rectangle line imageview.</p>
  
  <p><a href="https://i.stack.imgur.com/JGeJK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JGeJK.png" alt="enter image description here"></a></p>
  
  <p>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.</p>
  
  <pre><code>let cgImage = image.cgImage
  let croppedCGImage: CGImage = cgImage!.cropping(to: self.m_TrimArea.frame)!
  let uiImage = UIImage(cgImage: croppedCGImage)
  </code></pre>
  
  <p>Here self.m_TrimArea is an imageview which holds the blue rectangle line. Please give some guidance to achieve this. </p>