title: When using avfoundation - crop visible portion of captured image represented in display layer
body: <p>I am using <a href="https://github.com/piemonte/PBJVision" rel="noreferrer">PBJVision</a> library to capture images.</p>
  
  <p>Under the hood it is using AVFoundation.</p>
  
  <p>I set up the camera to use the following options</p>
  
  <pre><code>    PBJVision *camera = [[PBJVision alloc] init];
      self.camera = camera;
      self.camera.delegate = self;
      [self.camera setCameraMode:PBJCameraModePhoto];
      [self.camera setCameraDevice:PBJCameraDeviceFront];
      [self.camera setCameraOrientation:PBJCameraOrientationPortrait];
      [self.camera setFocusMode:PBJFocusModeAutoFocus];
      [self.camera setPresentationFrame:self.previewView.frame];
      [self.camera previewLayer].frame = self.previewView.bounds;
  
      [self.camera previewLayer].videoGravity = AVLayerVideoGravityResizeAspectFill;
  
      [self.previewView.layer addSublayer:[self.camera previewLayer]];
  </code></pre>
  
  <p>because the preview layer gravity is set as <code>AVLayerVideoGravityResizeAspectFill</code> the captured image isn't identical to the previewed image.</p>
  
  <p>How can I crop it according to the video gravity?</p>