title: How to compress of reduce the size of an image before uploading to Parse as PFFile? (Swift)
body: <p>I was trying to upload an image file to Parse after taking photo directly on phone. But it throws an exception: </p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'PFFile cannot be larger than 10485760 bytes'</p>
  </blockquote>
  
  <p>Here is my code: </p>
  
  <p>In first view controller:</p>
  
  <pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
      if (segue.identifier == "getImage")
      {
          var svc = segue.destinationViewController as! ClothesDetail
          svc.imagePassed = imageView.image
      }
  }
  </code></pre>
  
  <p>In view controller that uploads image:</p>
  
  <pre><code>let imageData = UIImagePNGRepresentation(imagePassed)
  let imageFile = PFFile(name: "\(picName).png", data: imageData)
  
  var userpic = PFObject(className:"UserPic")
  userpic["picImage"] = imageFile`
  </code></pre>
  
  <p>But I still need to upload that photo to Parse. Is there any way to reduce the size or resolution of the image?</p>