What is the best way to save CGImageRef to a png or jpeg file in iOS?
For a general cocoa application (not using UIkit), see: Saving CGImageRef to a png file? but this seems too long and clunky.
Using UIKit, the code becomes a simple 3-liner:
UIImage *uiImage = [UIImage imageWithCGImage:cgImage];
NSData *jpgData = UIImageJPEGRepresentation(uiImage, 0.9f);
[jpgData writeToFile:path atomically:NO];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With