title: Reducing the quality of a UIImage (compressing it)
body: <p>Hi I am trying to compress a UIImage my code is like so:</p>
  
  <pre><code>    var data = UIImageJPEGRepresentation(image, 1.0)
      print("Old image size is \(data?.length) bytes")
      data = UIImageJPEGRepresentation(image, 0.7)
      print("New image size is \(data?.length) bytes")
      let optimizedImage = UIImage(data: data!, scale: 1.0)
  </code></pre>
  
  <p>The print out is:</p>
  
  <pre><code>Old image size is Optional(5951798) bytes
  New image size is Optional(1416792) bytes
  </code></pre>
  
  <p>Later on in the app I upload the UIImage to a webserver (it's converted to NSData first). When I check the size it's the original 5951798 bytes. What could I be doing wrong here?</p>