Does anyone know how to save UIimage in png format to the library with swift UI?

I'm writing a project to modify the pixels of the picture with the swiftUI, but every time the modified Uiimage is saved to the system library, it will become jpg format. You know, jpg will compress the picture, thus changing the pixels of the picture, so I want to find a way to convert the UIimage into a png into a library or a file app.
Hi weiha,

Take a look at UIImagePNGRepresentation.

—jasonag.
how about just this:

Code Block
let img = UIImage(...)
img.pngData() // the data to be saved as png

Does anyone know how to save UIimage in png format to the library with swift UI?
 
 
Q