We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 790faa9 commit cfba89dCopy full SHA for cfba89d
Sources/ScriptToolkit/NSImageExtension.swift
@@ -62,8 +62,14 @@ public extension NSImage {
62
/// Saves the PNG representation of the current image to the HD.
63
///
64
/// - parameter url: The location url to which to write the png file.
65
- func savePNGRepresentationToURL(url: URL) throws {
+ func savePNGRepresentationToURL(url: URL, onlyChange: Bool) throws {
66
if let png = self.PNGRepresentation {
67
+ if let originalData = try? Data(contentsOf: url) {
68
+ if onlyChange && (png == originalData) {
69
+ return
70
+ }
71
72
+
73
try png.write(to: url, options: .atomicWrite)
74
}
75
0 commit comments