I am trying to save a UIImage object in a .jpeg file on a device and I use this code:
-(void)saveImageToDocumentsDirectory:(UIImage *)mimage withFileName:(NSString *)fileName { UIImageWriteToSavedPhotosAlbum(mimage,nil,nil,nil); NSData *dataForJPEGFile = UIImageJPEGRepresentation(mimage, 1.0); NSError *error2 = nil; if (![dataForJPEGFile writeToFile:[self getDirectoryFilePath:fileName] options:NSAtomicWrite error:&error2]) { return; } }
It will save the image of the .jpeg type, but it will take up too much memory compared to the UIImageWriteToSavedPhotosAlbum(mimage,nil,nil,nil) method UIImageWriteToSavedPhotosAlbum(mimage,nil,nil,nil) , which saves the same image object in the .jpeg type and the same quality.
My question is why so .. ??
source share