      */
     public static func loadFrom(_ file: String) -> NSImage! {
         // Loading directly with NSImage, doesn't take in account of scale
-        let imageReps = NSBitmapImageRep.imageReps(withContentsOfFile: file)
-        if (imageReps != nil) {
+        if let imageReps = NSBitmapImageRep.imageReps(withContentsOfFile: file) {
             var width = 0
             var height = 0
             
-            for rep in imageReps! {
+            for rep in imageReps {
                 if (rep.pixelsWide > width) {
                     width = rep.pixelsWide
                 }

        NSGraphicsContext.restoreGraphicsState()
        
        var ok = false
        let imageData = bitmap.representation(using: NSBitmapImageFileType.PNG,
                                                       properties: [NSImageCompressionFactor: 1.0])
        if (imageData != nil) {
            ok = (try? imageData!.write(to: URL(fileURLWithPath: (file as NSString).standardizingPath), options: [.atomic])) != nil
        }
        if (ok == false) {
            Utils.error("Error: Can't save image to \(file)")

            }
            let newImage = NSImage(size: NSMakeSize(CGFloat(width), CGFloat(height)))
            newImage.setName(file.lastPathComponent())
            newImage.addRepresentations(imageReps)
            return newImage
        }
        return nil
