CHGenerator/WebsiteGenerator/Extensions/NSImage+Extensions.swift

16 lines
347 B
Swift
Raw Normal View History

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) { (resizedRect) -> Bool in
self.draw(in: resizedRect)
return true
}
}
}