Does the iPhone compress images saved within my app's documents directory?
<p>We are caching images downloaded from our server. We get the data from an ASIHTTPRequest callback like this:</p>

<pre><code>#pragma mark ASIHTTPRequest callback
-(void)imageDownloadFinished:(ASIHTTPRequest*)aRequest
{
    NSString* fileName = aRequest.url.path.lastPathComponent; 
    [self imageDidArrive:[aRequest responseData] forFileName:fileName];
}
</code></pre>

<p>We write the image data to our local storage like this:</p>

<pre><code> NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
 NSString *documentsDirectory = [paths objectAtIndex:0] ; 
 NSString* folder = [[documentsDirectory stringByAppendingPathComponent:@"flook.images"] retain];
        NSString* fileName = [folder stringByAppendingFormat:@"/%@", aBaseFilename];

 BOOL writeSuccess = [anImageData writeToFile:fileName atomically:NO];
</code></pre>

<p>The downloaded images are always the expected size, around 45-85KB.</p>

<p>Later, we read images from our cache like this:</p>

<pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
 NSString *documentsDirectory = [paths objectAtIndex:0] ; 
 NSString* folder = [[documentsDirectory stringByAppendingPathComponent:@"flook.images"] retain];
        NSString* fileName = [folder stringByAppendingFormat:@"/%@", aBaseFilename];

 image = [UIImage imageWithContentsOfFile:fileName];
</code></pre>

<p>Occasionally, the images returned from this cache read are much smaller because they are much more compressed - around 5-10KB. Has the OS done this to us?</p>

<p>Edit - it turns out that we are downloading the small images, so the issue isn't on the iPhone</p>
