title: How to compress/resize image on iOS before uploading to a server?
body: <p>I'm currently uploading an image to a server using Imgur on iOS with the following code:</p>
  
  <pre><code>NSData* imageData = UIImagePNGRepresentation(image);
  NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString* fullPathToFile = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"SBTempImage.png"];
  [imageData writeToFile:fullPathToFile atomically:NO];
  
  [uploadRequest setFile:fullPathToFile forKey:@"image"];
  </code></pre>
  
  <p>The code works fine when run in the simulator and uploading a file from the simulator's photo library because I'm on a fast ethernet connection. However, the same code times out on the iPhone when selecting an image taken with the iPhone. So, I tried it by saving a small image from the web and attempting to upload that, which worked.</p>
  
  <p>This leads me to believe the large images taken by the iPhone are timing out over the somewhat slow 3G network. Is there any way to compress/resize the image from the iPhone before sending it?</p>