2022-08-26 17:40:51 +02:00
|
|
|
import Foundation
|
|
|
|
import AppKit
|
|
|
|
|
|
|
|
extension NSImage {
|
|
|
|
|
|
|
|
func scaledDown(to size: NSSize) -> NSImage {
|
|
|
|
guard self.size.width > size.width else {
|
|
|
|
return self
|
|
|
|
}
|
2022-09-26 17:00:25 +02:00
|
|
|
return NSImage(size: size, flipped: false) { [weak self] (resizedRect) -> Bool in
|
|
|
|
self?.draw(in: resizedRect)
|
2022-08-26 17:40:51 +02:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|