File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -353,6 +353,15 @@ Convert a String to Data then save it to the given URL path
353
353
```swift
354
354
saveAsPNG (path :URL) -> Bool
355
355
```
356
+
357
+ Save an image to a temporary file
358
+
359
+ ```swift
360
+ tempURLForImage (named name: String ) -> URL?
361
+ ```
362
+
363
+ Resize an image
364
+
356
365
```swift
357
366
resize (width : CGFloat) -> UIImage
358
367
resize (height : CGFloat) -> UIImage
Original file line number Diff line number Diff line change @@ -33,6 +33,21 @@ extension UIImage {
33
33
}
34
34
return true
35
35
}
36
+
37
+ #if !IS_EXTENSION
38
+ /**
39
+ Saves a `UIImage` to the temporary directory as a `.png` and returns the URL
40
+ - Parameters:
41
+ - named: The filename to use (`.png` will automatically be appended)
42
+ */
43
+ func tempURLForImage( named name: String ) -> URL ? {
44
+
45
+ let fileManager = FileManager . default
46
+ let url = fileManager. temporaryDirectory. appendingPathComponent ( " \( name) .png " )
47
+ guard self . saveAsPNG ( path: url) else { return nil }
48
+ return url
49
+ }
50
+ #endif
36
51
}
37
52
38
53
public
You can’t perform that action at this time.
0 commit comments