title: Not getting full resolution from AVFoundation camera
body: <p>I'm struggling to get the full resolution when I grab a photo using the AVFoundation. It works fine with the code below but the image is 1080x1920.  Yet I know the iPhone5 camera I'm using is 2448x3264.</p>
  
  <p>Setting the stillImageOutput with this:</p>
  
  <pre><code>AVCaptureDevice *videoDevice = 
   [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
  NSError *error;
  videoIn = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&amp;error];
  [session canAddInput:videoIn];
  [session addInput:videoIn];
  
  stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
  if ([session canAddOutput:stillImageOutput]) {
      [stillImageOutput setOutputSettings:@{AVVideoCodecKey : AVVideoCodecJPEG}];
      [session addOutput:stillImageOutput];
  }
  </code></pre>
  
  <p>Then getting it with:</p>
  
  <pre><code>// Sort orientation
  [[stillImageOutput connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:[previewLayer.connection videoOrientation]];
  
  // Set the flash to auto
  [self setFlashMode:AVCaptureFlashModeAuto forDevice:[videoIn device]];
  
  // Capture a still image.
  [stillImageOutput captureStillImageAsynchronouslyFromConnection:[stillImageOutput connectionWithMediaType:AVMediaTypeVideo] completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
  
      if (imageDataSampleBuffer)
      {
          NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
          UIImage *image = [[UIImage alloc] initWithData:imageData];
  
          NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/ImageTaken.jpg"];
          NSData *imageToWriteData = UIImageJPEGRepresentation(image, 0.9f);
          [imageToWriteData writeToFile:jpgPath atomically:YES];
      }
  }];
  </code></pre>
  
  <p>I have a Preview and when the user takes the picture I want it to be what they are previewing but when I do that in the code above it gives me the lower resolution.  I understand that the video is done in a lower resolution but how do I get the AVFoundation to use the camera part not just take a frame from the video?</p>
  
  <p>Mike</p>