Hi guys,
I'm facing a problem when saving an UIImage, instanciated from data received from an HTTP request, in a file : the file is HUGE, way heavier than the size of the data returned by the HTTP request.
For example, when downloading an image from a given URL, the retrieved data length is around 1.2MB. I then instanciate my UIImage with...
UIImage *myImage = [UIImage imageWithData:responseData];
...and then save the image to the disk with this :
NSData *imageData = UIImageJPEGRepresentation(myImage, 1.0);
[imageData writeToFile:filePath atomically:YES];
The resulting file weight is around 5MB !
I know I could just save the received data to the file instead of first instanciating an UIImage and then retrieve its data back with UIImageJPEGRepresentation, but I'm curious to know why the file size is so huge when using this method.
Any hint ?
Thanks by advance,
Eric.
EDIT :
I can confirm that saving the response data to the file instead of first instanciating an UIImage solve the problem and generate a file of around the same size than the data. Still, I wonder why the size change so much when saving from an UIImage...