Answer by Torianin for How do I save a UIImage to a file?
In Swift 4.2:// Create path.let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)if let filePath = paths.first?.appendingPathComponent("MyImageName.png") { // Save image....
View ArticleAnswer by Samo for How do I save a UIImage to a file?
In Swift 4:// Create path.let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)if let filePath = paths.first?.appendingPathComponent("MyImageName.png") { // Save image. do...
View ArticleAnswer by neoneye for How do I save a UIImage to a file?
extension UIImage { /// Save PNG in the Documents directory func save(_ name: String) { let path: String = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! let url...
View ArticleAnswer by NatashaTheRobot for How do I save a UIImage to a file?
In Swift 3:// Create path.let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)let filePath = "\(paths[0])/MyImageName.png"// Save...
View ArticleAnswer by Alex the Ukrainian for How do I save a UIImage to a file?
The above are useful, but they don't answer your question of how to save in a subdirectory or get the image from a UIImagePicker. First, you must specify that your controller implements image picker's...
View ArticleAnswer by Maggie for How do I save a UIImage to a file?
NSData *imageData = UIImagePNGRepresentation(image);[imageData writeToFile:path atomically:YES];where path is the name of the file you want to write it to.
View ArticleAnswer by lu yuan for How do I save a UIImage to a file?
First you should get the Documents directory/* create path to cache directory inside the application's Documents directory */NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,...
View ArticleAnswer by DrummerB for How do I save a UIImage to a file?
Of course you can create subfolders in the documents folder of your app. You use NSFileManager to do that.You use UIImagePNGRepresentation to convert your image to NSData and save that to disk.//...
View ArticleAnswer by Sergey Kalinichenko for How do I save a UIImage to a file?
You have to construct a representation of your image as a particular format (say, JPEG or PNG), and then call writeToFile:atomically: on the representation:UIImage *image = ...;NSString *path =...
View ArticleHow do I save a UIImage to a file?
If I have a UIImage from an imagePicker, how can I save it to a subfolder in the documents directory?
View Article