Resize NSImage Proportionally (Swift)

I wanted a simple function to resize an image to a desired height, while keeping proportions. Here’s what I came up with (based on Marco implementation): extension NSImage {          func resizedImageTo(sourceImage: NSImage, newSize: NSSize) -> NSImage?{         if sourceImage.isValid == false {             …