Issue #795

extension NSImage {
    func resize(width: CGFloat, height: CGFloat, padding: CGFloat) -> NSImage {
        let img = NSImage(size: CGSize(width: width, height: height))

        img.lockFocus()
        let ctx = NSGraphicsContext.current
        ctx?.imageInterpolation = .high
        self.draw(
            in: NSMakeRect(0, 0, width, height),
            from: NSMakeRect(0, -padding, size.width, size.height - padding),
            operation: .copy,
            fraction: 1
        )
        img.unlockFocus()

        return img
    }
}

So we can use like

button.image = NSImage(named: NSImage.Name("pastePal"))?.resize(width: 22, height: 22, padding: -4)