title: Cropping center square of UIImage
body: <p>So here's where I've made it so far.  I am using a UIImage captured from the camera and can crop the center square when in landscape.  For some reason this doesn't translate to portrait mode as expected.  I'll post my code and logs just for reference.</p>
  
  <p>Code:</p>
  
  <pre><code>CGRect squareRect = CGRectMake(offsetX, offsetY, newWidth, newHeight);
  CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], squareRect);
  image = [UIImage imageWithCGImage:imageRef scale:1 orientation:image.imageOrientation];
  </code></pre>
  
  <p>Portrait results (not square):</p>
  
  <pre><code>original image size: {1536, 2048}, with orientation: 3
  squareRect: {{0, 256}, {1536, 1536}}
  new image size: {1280, 1536}, with orientation: 3 &lt;--- not expected
  </code></pre>
  
  <p>Landscape results (square):</p>
  
  <pre><code>original image size: {2048, 1536}, with orientation: 1
  squareRect: {{256, 0}, {1536, 1536}}
  new image size: {1536, 1536}, with orientation: 1
  </code></pre>
  
  <p>Is this a bug within CGImageCreateWithImageInRect() or am I missing something here?</p>