swiftobjective-ccocoacore-graphicscgimage

Saving CGImageRef to a png file?


in my Cocoa application, I load a .jpg file from disk, manipulate it. Now it needs to be written to disk as a .png file. How can you do that?

Thanks for your help!


Solution

  • Create a CGImageDestination, passing kUTTypePNG as the type of file to create. Add the image, then finalize the destination.