title: How to take square picture in iphone with avFoundation like in Instagram app?
body: <p>I am taking photo with AVFoundation like here:
  <a href="http://red-glasses.com/index.php/tutorials/ios4-take-photos-with-live-video-preview-using-avfoundation/">http://red-glasses.com/index.php/tutorials/ios4-take-photos-with-live-video-preview-using-avfoundation/</a></p>
  
  <p>One snippet:</p>
  
  <pre><code>[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
   {
       CFDictionaryRef exifAttachments = CMGetAttachment( imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
       if (exifAttachments)
       {
           // Do something with the attachments.
           NSLog(@"attachements: %@", exifAttachments);
       }
       else
           NSLog(@"no attachments");
  
       NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
       UIImage *image = [[UIImage alloc] initWithData:imageData];
  </code></pre>
  
  <p>Picture size as far as i found out is set here:</p>
  
  <pre><code>   AVCaptureSession *session = [[AVCaptureSession alloc] init];  
     session.sessionPreset =AVCaptureSessionPresetMedium; //medium on my iphone4 is 640*480
  </code></pre>
  
  <p>But here are only few settings possible and cant be set to custom size.</p>
  
  <p>I would like taken pictures to have aspect ratio 1:1 if possible, for example 400x400 pixels (square pictures).
  It seems instagram is doing it (or are they cropping images?). </p>
  
  <p>How can i specify the size of taken picture to be square? I know how to change size on the phone, but if the taken picture is not square, the result is not good.</p>
  
  <p>Any idea?</p>