blob: c24c0cf4c5f4209a94bd77bbd6c17b3cf503fb88 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import Cocoa
extension NSImage {
public func writePNG(toURL url: URL) {
guard let data = tiffRepresentation,
let rep = NSBitmapImageRep(data: data),
let imgData = rep.representation(
using: .png, properties: [.compressionFactor: NSNumber(floatLiteral: 1.0)])
else {
print(
"\(self.self) Error Function '\(#function)' Line: \(#line) No tiff rep found for image writing to \(url)"
)
return
}
do {
try imgData.write(to: url)
} catch let error {
print(
"\(self.self) Error Function '\(#function)' Line: \(#line) \(error.localizedDescription)")
}
}
}
|