title: Converting UIImage to PFFile results in huge file
body: <p>I want to upload an image to the parse servers. A <code>PFFile</code> can only be 10mb max, so I wrote an category to check if the <code>UIImage</code> bytesize doesn't exceeds that.</p>
  
  <p>This is the code in my category: </p>
  
  <pre><code>- (UIImage *)scaleImageToSize:(CGFloat)destSize{
      UIImage *img = self;
      NSData *imgData = UIImageJPEGRepresentation(img, 1.0);
      NSLog(@"size: %lu", (unsigned long)[imgData length]);
      while ([imgData length] &gt; destSize) {
          UIImageJPEGRepresentation(img, 0.9);
          NSLog(@"new size: %lu",(unsigned long)[imgData length]);
      }
  
      return img;
  }
  </code></pre>
  
  <p>However when I call <code>[image scaleImageToSize:10485760];</code>. It's most of the time smaller than that.</p>
  
  <p>However, after the having run the following line:</p>
  
  <pre><code>photoFile = [PFFile fileWithData:UIImagePNGRepresentation(image)];
  </code></pre>
  
  <p>the <code>[photoFile fileSize]</code> suddently exceeds <code>10485760</code>. How is that possible? How can I prevent photos from getting too large once they're a <code>PFFile</code>?</p>