NSData to UIImage back to NSData resulting length size tripled
<p>I am doing a simple image file size reduction task but got this issue. When using no-loss option for JPEGs, the file size tripled then the original NSData for the image (same resolution). Any suggestion? </p>

<p>Here is the simple code:</p>

<pre><code>let data = someImageData
print(data.length)
let image = UIImage(data: data)!
let newImageData = UIImageJPEGRepresentation(image, 1)
print(newImageData.length)
let newImageData = UIImageJPEGRepresentation(image, 0.8)
print(newImageData.length)
</code></pre>

<p>and output:</p>

<pre><code>2604768  //original length
8112955  //new length if compression = 1
2588870  //new length if compression = 0.8
</code></pre>

<p>It seems I have to take the 0.8 quality loss to get the same data length. Did I miss something? Pease help.</p>

<p>Edit: I did some more test by converting the data to UIImage then to UIImageJPEGRepresentation(image, 1), the length size of the new data increases every cycle. But if I use UIImageJPEGRepresentation(image, 0.8), the length size of the new data decreases a bit (very little), however, the compound qualify loss should be a concern.</p>