I want to convert an image to either
UIImagePNGRepresentation
UIImageJPEGRepresentation
however I do not know the file type. I've just got a URL with no extension. Is there anyway to save the image from the URL to the filesystem?
// got the data from the URL
let imageData = UIImage(data: data!)
// now I want to write to the filesystem but only way was with a representation as UIImage has no write
if let saveImageData = UIImageXXXXXXRepresentation(imageData!) {
try saveImageData.write(to: URL(fileURLWithPath: localFilename), options: [.atomic])
}