16 lines
360 B
Swift
16 lines
360 B
Swift
import Foundation
|
|
import AppKit
|
|
|
|
extension NSImage {
|
|
|
|
func scaledDown(to size: NSSize) -> NSImage {
|
|
guard self.size.width > size.width else {
|
|
return self
|
|
}
|
|
return NSImage(size: size, flipped: false) { [weak self] (resizedRect) -> Bool in
|
|
self?.draw(in: resizedRect)
|
|
return true
|
|
}
|
|
}
|
|
}
|